From 1085ecdaba670d93df00048f62cc88c8720fd43f Mon Sep 17 00:00:00 2001 From: dherrada Date: Thu, 12 Mar 2020 19:39:21 -0400 Subject: [PATCH 1/3] Ran black, updated to pylint 2.x --- .github/workflows/build.yml | 2 +- adafruit_lsm6ds.py | 150 +++++++++++++++++++++-------------- docs/conf.py | 120 +++++++++++++++++----------- examples/lsm6ds_full_test.py | 19 +++-- examples/lsm6ds_pedometer.py | 5 +- examples/lsm6ds_rate_test.py | 19 +++-- setup.py | 56 ++++++------- 7 files changed, 218 insertions(+), 153 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fff3aa9..1dad804 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,7 +40,7 @@ jobs: source actions-ci/install.sh - name: Pip install pylint, black, & Sphinx run: | - pip install --force-reinstall pylint==1.9.2 black==19.10b0 Sphinx sphinx-rtd-theme + pip install --force-reinstall pylint black==19.10b0 Sphinx sphinx-rtd-theme - name: Library version run: git describe --dirty --always --tags - name: PyLint diff --git a/adafruit_lsm6ds.py b/adafruit_lsm6ds.py index 832e6af..8254f59 100644 --- a/adafruit_lsm6ds.py +++ b/adafruit_lsm6ds.py @@ -54,11 +54,12 @@ from adafruit_register.i2c_struct import ROUnaryStruct, Struct from adafruit_register.i2c_bits import RWBits from adafruit_register.i2c_bit import RWBit + __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_LSM6DSOX.git" -_LSM6DS_DEFAULT_ADDRESS = const(0x6a) +_LSM6DS_DEFAULT_ADDRESS = const(0x6A) _LSM6DS_CHIP_ID = const(0x6C) _ISM330DHCT_CHIP_ID = const(0x6B) @@ -95,6 +96,7 @@ _MILLI_G_TO_ACCEL = 0.00980665 + class CV: """struct helper""" @@ -115,62 +117,82 @@ def is_valid(cls, value): "Returns true if the given value is a member of the CV" return value in cls.string + class AccelRange(CV): """Options for ``accelerometer_range``""" - pass #pylint: disable=unnecessary-pass -AccelRange.add_values(( - ('RANGE_2G', 0, 2, 0.061), - ('RANGE_16G', 1, 16, 0.488), - ('RANGE_4G', 2, 4, 0.122), - ('RANGE_8G', 3, 8, 0.244) -)) + pass # pylint: disable=unnecessary-pass + + +AccelRange.add_values( + ( + ("RANGE_2G", 0, 2, 0.061), + ("RANGE_16G", 1, 16, 0.488), + ("RANGE_4G", 2, 4, 0.122), + ("RANGE_8G", 3, 8, 0.244), + ) +) + class GyroRange(CV): """Options for ``gyro_data_range``""" - pass #pylint: disable=unnecessary-pass -GyroRange.add_values(( - ('RANGE_125_DPS', 125, 125, 4.375), - ('RANGE_250_DPS', 0, 250, 8.75), - ('RANGE_500_DPS', 1, 500, 17.50), - ('RANGE_1000_DPS', 2, 1000, 35.0), - ('RANGE_2000_DPS', 3, 2000, 70.0), - ('RANGE_4000_DPS', 4000, 4000, 140.0) -)) + pass # pylint: disable=unnecessary-pass + + +GyroRange.add_values( + ( + ("RANGE_125_DPS", 125, 125, 4.375), + ("RANGE_250_DPS", 0, 250, 8.75), + ("RANGE_500_DPS", 1, 500, 17.50), + ("RANGE_1000_DPS", 2, 1000, 35.0), + ("RANGE_2000_DPS", 3, 2000, 70.0), + ("RANGE_4000_DPS", 4000, 4000, 140.0), + ) +) + class Rate(CV): """Options for ``accelerometer_data_rate`` and ``gyro_data_rate``""" - pass #pylint: disable=unnecessary-pass - -Rate.add_values(( - ('RATE_SHUTDOWN', 0, 0, None), - ('RATE_12_5_HZ', 1, 12.5, None), - ('RATE_26_HZ', 2, 26.0, None), - ('RATE_52_HZ', 3, 52.0, None), - ('RATE_104_HZ', 4, 104.0, None), - ('RATE_208_HZ', 5, 208.0, None), - ('RATE_416_HZ', 6, 416.0, None), - ('RATE_833_HZ', 7, 833.0, None), - ('RATE_1_66K_HZ', 8, 1066.0, None), - ('RATE_3_33K_HZ', 9, 3033.0, None), - ('RATE_6_66K_HZ', 10, 6066.0, None), - ('RATE_1_6_HZ', 11, 1.6, None) -)) + + pass # pylint: disable=unnecessary-pass + + +Rate.add_values( + ( + ("RATE_SHUTDOWN", 0, 0, None), + ("RATE_12_5_HZ", 1, 12.5, None), + ("RATE_26_HZ", 2, 26.0, None), + ("RATE_52_HZ", 3, 52.0, None), + ("RATE_104_HZ", 4, 104.0, None), + ("RATE_208_HZ", 5, 208.0, None), + ("RATE_416_HZ", 6, 416.0, None), + ("RATE_833_HZ", 7, 833.0, None), + ("RATE_1_66K_HZ", 8, 1066.0, None), + ("RATE_3_33K_HZ", 9, 3033.0, None), + ("RATE_6_66K_HZ", 10, 6066.0, None), + ("RATE_1_6_HZ", 11, 1.6, None), + ) +) + class AccelHPF(CV): """Options for the accelerometer high pass filter""" - pass #pylint: disable=unnecessary-pass -AccelHPF.add_values(( - ('SLOPE', 0, 0, None), - ('HPF_DIV100', 1, 0, None), - ('HPF_DIV9', 2, 0, None), - ('HPF_DIV400', 3, 0, None), -)) + pass # pylint: disable=unnecessary-pass + + +AccelHPF.add_values( + ( + ("SLOPE", 0, 0, None), + ("HPF_DIV100", 1, 0, None), + ("HPF_DIV9", 2, 0, None), + ("HPF_DIV400", 3, 0, None), + ) +) -class LSM6DS: #pylint: disable=too-many-instance-attributes +class LSM6DS: # pylint: disable=too-many-instance-attributes """Driver for the LSM6DSOX 6-axis accelerometer and gyroscope. @@ -179,11 +201,11 @@ class LSM6DS: #pylint: disable=too-many-instance-attributes """ -#ROUnaryStructs: + # ROUnaryStructs: _chip_id = ROUnaryStruct(_LSM6DS_WHOAMI, " Date: Tue, 14 Apr 2020 16:39:55 -0400 Subject: [PATCH 2/3] Reformatted using black py35 --- docs/conf.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 84eba05..d3dfe22 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -46,18 +46,18 @@ master_doc = "index" # General information about the project. -project = u"Adafruit LSM6DSOX Library" -copyright = u"2019 Bryan Siepert" -author = u"Bryan Siepert" +project = "Adafruit LSM6DSOX Library" +copyright = "2019 Bryan Siepert" +author = "Bryan Siepert" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = u"1.0" +version = "1.0" # The full version, including alpha/beta/rc tags. -release = u"1.0" +release = "1.0" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -148,7 +148,7 @@ ( master_doc, "AdafruitLSM6DSOXLibrary.tex", - u"AdafruitLSM6DSOX Library Documentation", + "AdafruitLSM6DSOX Library Documentation", author, "manual", ), @@ -162,7 +162,7 @@ ( master_doc, "AdafruitLSM6DSOXlibrary", - u"Adafruit LSM6DSOX Library Documentation", + "Adafruit LSM6DSOX Library Documentation", [author], 1, ) @@ -177,7 +177,7 @@ ( master_doc, "AdafruitLSM6DSOXLibrary", - u"Adafruit LSM6DSOX Library Documentation", + "Adafruit LSM6DSOX Library Documentation", author, "AdafruitLSM6DSOXLibrary", "One line description of project.", From cf745c954ce15fd87f51b83d4df96d625e8d403d Mon Sep 17 00:00:00 2001 From: dherrada Date: Tue, 14 Apr 2020 16:42:01 -0400 Subject: [PATCH 3/3] Reformatted again --- adafruit_lsm6ds.py | 1 + 1 file changed, 1 insertion(+) diff --git a/adafruit_lsm6ds.py b/adafruit_lsm6ds.py index 024e01f..436e670 100644 --- a/adafruit_lsm6ds.py +++ b/adafruit_lsm6ds.py @@ -135,6 +135,7 @@ class AccelRange(CV): class GyroRange(CV): """Options for ``gyro_data_range``""" + GyroRange.add_values( ( ("RANGE_125_DPS", 125, 125, 4.375),