Skip to content

Commit 57f6496

Browse files
authored
Merge pull request #7 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents 8dffc03 + ebc4b91 commit 57f6496

File tree

7 files changed

+154
-124
lines changed

7 files changed

+154
-124
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
source actions-ci/install.sh
4141
- name: Pip install pylint, black, & Sphinx
4242
run: |
43-
pip install --force-reinstall pylint==1.9.2 black==19.10b0 Sphinx sphinx-rtd-theme
43+
pip install --force-reinstall pylint black==19.10b0 Sphinx sphinx-rtd-theme
4444
- name: Library version
4545
run: git describe --dirty --always --tags
4646
- name: PyLint

adafruit_mpu6050.py

Lines changed: 50 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -54,32 +54,34 @@
5454
from adafruit_register.i2c_bit import RWBit
5555
from adafruit_register.i2c_bits import RWBits
5656
import adafruit_bus_device.i2c_device as i2c_device
57+
5758
# pylint: disable=bad-whitespace
58-
_MPU6050_DEFAULT_ADDRESS = 0x68 # MPU6050 default i2c address w/ AD0 low
59-
_MPU6050_DEVICE_ID = 0x68 # The correct MPU6050_WHO_AM_I value
60-
61-
_MPU6050_SELF_TEST_X = 0x0D # Self test factory calibrated values register
62-
_MPU6050_SELF_TEST_Y = 0x0E # Self test factory calibrated values register
63-
_MPU6050_SELF_TEST_Z = 0x0F # Self test factory calibrated values register
64-
_MPU6050_SELF_TEST_A = 0x10 # Self test factory calibrated values register
65-
_MPU6050_SMPLRT_DIV = 0x19 # sample rate divisor register
66-
_MPU6050_CONFIG = 0x1A # General configuration register
67-
_MPU6050_GYRO_CONFIG = 0x1B # Gyro specfic configuration register
68-
_MPU6050_ACCEL_CONFIG = 0x1C # Accelerometer specific configration register
69-
_MPU6050_INT_PIN_CONFIG = 0x37 # Interrupt pin configuration register
70-
_MPU6050_ACCEL_OUT = 0x3B # base address for sensor data reads
71-
_MPU6050_TEMP_OUT = 0x41 # Temperature data high byte register
72-
_MPU6050_GYRO_OUT = 0x43 # base address for sensor data reads
73-
_MPU6050_SIG_PATH_RESET = 0x68 # register to reset sensor signal paths
74-
_MPU6050_USER_CTRL = 0x6A # FIFO and I2C Master control register
75-
_MPU6050_PWR_MGMT_1 = 0x6B # Primary power/sleep control register
76-
_MPU6050_PWR_MGMT_2 = 0x6C # Secondary power/sleep control register
77-
_MPU6050_WHO_AM_I = 0x75 # Divice ID register
59+
_MPU6050_DEFAULT_ADDRESS = 0x68 # MPU6050 default i2c address w/ AD0 low
60+
_MPU6050_DEVICE_ID = 0x68 # The correct MPU6050_WHO_AM_I value
61+
62+
_MPU6050_SELF_TEST_X = 0x0D # Self test factory calibrated values register
63+
_MPU6050_SELF_TEST_Y = 0x0E # Self test factory calibrated values register
64+
_MPU6050_SELF_TEST_Z = 0x0F # Self test factory calibrated values register
65+
_MPU6050_SELF_TEST_A = 0x10 # Self test factory calibrated values register
66+
_MPU6050_SMPLRT_DIV = 0x19 # sample rate divisor register
67+
_MPU6050_CONFIG = 0x1A # General configuration register
68+
_MPU6050_GYRO_CONFIG = 0x1B # Gyro specfic configuration register
69+
_MPU6050_ACCEL_CONFIG = 0x1C # Accelerometer specific configration register
70+
_MPU6050_INT_PIN_CONFIG = 0x37 # Interrupt pin configuration register
71+
_MPU6050_ACCEL_OUT = 0x3B # base address for sensor data reads
72+
_MPU6050_TEMP_OUT = 0x41 # Temperature data high byte register
73+
_MPU6050_GYRO_OUT = 0x43 # base address for sensor data reads
74+
_MPU6050_SIG_PATH_RESET = 0x68 # register to reset sensor signal paths
75+
_MPU6050_USER_CTRL = 0x6A # FIFO and I2C Master control register
76+
_MPU6050_PWR_MGMT_1 = 0x6B # Primary power/sleep control register
77+
_MPU6050_PWR_MGMT_2 = 0x6C # Secondary power/sleep control register
78+
_MPU6050_WHO_AM_I = 0x75 # Divice ID register
7879

7980
STANDARD_GRAVITY = 9.80665
8081
# pylint: enable=bad-whitespace
8182

82-
class Range: # pylint: disable=too-few-public-methods
83+
84+
class Range: # pylint: disable=too-few-public-methods
8385
"""Allowed values for `accelerometer_range`.
8486
8587
- ``Range.RANGE_2_G``
@@ -88,12 +90,14 @@ class Range: # pylint: disable=too-few-public-methods
8890
- ``Range.RANGE_16_G``
8991
9092
"""
93+
9194
RANGE_2_G = 0 # +/- 2g (default value)
9295
RANGE_4_G = 1 # +/- 4g
9396
RANGE_8_G = 2 # +/- 8g
94-
RANGE_16_G = 3 # +/- 16g
97+
RANGE_16_G = 3 # +/- 16g
9598

96-
class GyroRange: # pylint: disable=too-few-public-methods
99+
100+
class GyroRange: # pylint: disable=too-few-public-methods
97101
"""Allowed values for `gyro_range`.
98102
99103
- ``GyroRange.RANGE_250_DPS``
@@ -102,12 +106,14 @@ class GyroRange: # pylint: disable=too-few-public-methods
102106
- ``GyroRange.RANGE_2000_DPS``
103107
104108
"""
109+
105110
RANGE_250_DPS = 0 # +/- 250 deg/s (default value)
106111
RANGE_500_DPS = 1 # +/- 500 deg/s
107-
RANGE_1000_DPS = 2 # +/- 1000 deg/s
108-
RANGE_2000_DPS = 3 # +/- 2000 deg/s
112+
RANGE_1000_DPS = 2 # +/- 1000 deg/s
113+
RANGE_2000_DPS = 3 # +/- 2000 deg/s
114+
109115

110-
class Bandwidth: # pylint: disable=too-few-public-methods
116+
class Bandwidth: # pylint: disable=too-few-public-methods
111117
"""Allowed values for `filter_bandwidth`.
112118
113119
- ``Bandwidth.BAND_260_HZ``
@@ -119,15 +125,17 @@ class Bandwidth: # pylint: disable=too-few-public-methods
119125
- ``Bandwidth.BAND_5_HZ``
120126
121127
"""
122-
BAND_260_HZ = 0 # Docs imply this disables the filter
123-
BAND_184_HZ = 1 # 184 Hz
128+
129+
BAND_260_HZ = 0 # Docs imply this disables the filter
130+
BAND_184_HZ = 1 # 184 Hz
124131
BAND_94_HZ = 2 # 94 Hz
125132
BAND_44_HZ = 3 # 44 Hz
126133
BAND_21_HZ = 4 # 21 Hz
127134
BAND_10_HZ = 5 # 10 Hz
128-
BAND_5_HZ = 6 # 5 Hz
135+
BAND_5_HZ = 6 # 5 Hz
136+
129137

130-
class Rate: # pylint: disable=too-few-public-methods
138+
class Rate: # pylint: disable=too-few-public-methods
131139
"""Allowed values for `cycle_rate`.
132140
133141
- ``Rate.CYCLE_1_25_HZ``
@@ -136,10 +144,12 @@ class Rate: # pylint: disable=too-few-public-methods
136144
- ``Rate.CYCLE_40_HZ``
137145
138146
"""
139-
CYCLE_1_25_HZ = 0 # 1.25 Hz
140-
CYCLE_5_HZ = 1 # 5 Hz
141-
CYCLE_20_HZ = 2 # 20 Hz
142-
CYCLE_40_HZ = 3 # 40 Hz
147+
148+
CYCLE_1_25_HZ = 0 # 1.25 Hz
149+
CYCLE_5_HZ = 1 # 5 Hz
150+
CYCLE_20_HZ = 2 # 20 Hz
151+
CYCLE_40_HZ = 3 # 40 Hz
152+
143153

144154
class MPU6050:
145155
"""Driver for the MPU6050 6-DoF accelerometer and gyroscope.
@@ -148,6 +158,7 @@ class MPU6050:
148158
:param address: The I2C slave address of the sensor
149159
150160
"""
161+
151162
def __init__(self, i2c_bus, address=_MPU6050_DEFAULT_ADDRESS):
152163
self.i2c_device = i2c_device.I2CDevice(i2c_bus, address)
153164

@@ -161,20 +172,19 @@ def __init__(self, i2c_bus, address=_MPU6050_DEFAULT_ADDRESS):
161172
self._gyro_range = GyroRange.RANGE_500_DPS
162173
self._accel_range = Range.RANGE_2_G
163174
sleep(0.100)
164-
self._clock_source = 1 # set to use gyro x-axis as reference
175+
self._clock_source = 1 # set to use gyro x-axis as reference
165176
sleep(0.100)
166177
self.sleep = False
167178
sleep(0.010)
168179

169-
170180
def reset(self):
171181
"""Reinitialize the sensor"""
172182
self._reset = True
173183
while self._reset is True:
174184
sleep(0.001)
175185
sleep(0.100)
176186

177-
_signal_path_reset = 0b111 # reset all sensors
187+
_signal_path_reset = 0b111 # reset all sensors
178188
sleep(0.100)
179189

180190
_clock_source = RWBits(3, _MPU6050_PWR_MGMT_1, 0)
@@ -254,9 +264,9 @@ def gyro(self):
254264
gyro_scale = 16.4
255265

256266
# setup range dependant scaling
257-
gyro_x = (raw_x / gyro_scale)
258-
gyro_y = (raw_y / gyro_scale)
259-
gyro_z = (raw_z / gyro_scale)
267+
gyro_x = raw_x / gyro_scale
268+
gyro_y = raw_y / gyro_scale
269+
gyro_z = raw_z / gyro_scale
260270

261271
return (gyro_x, gyro_y, gyro_z)
262272

docs/conf.py

Lines changed: 73 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22

33
import os
44
import sys
5-
sys.path.insert(0, os.path.abspath('..'))
5+
6+
sys.path.insert(0, os.path.abspath(".."))
67

78
# -- General configuration ------------------------------------------------
89

910
# Add any Sphinx extension module names here, as strings. They can be
1011
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
1112
# ones.
1213
extensions = [
13-
'sphinx.ext.autodoc',
14-
'sphinx.ext.intersphinx',
15-
'sphinx.ext.napoleon',
16-
'sphinx.ext.todo',
14+
"sphinx.ext.autodoc",
15+
"sphinx.ext.intersphinx",
16+
"sphinx.ext.napoleon",
17+
"sphinx.ext.todo",
1718
]
1819

1920
# TODO: Please Read!
@@ -23,29 +24,40 @@
2324
autodoc_mock_imports = ["adafruit_register", "adafruit_bus_device"]
2425

2526

26-
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None),'Register': ('https://circuitpython.readthedocs.io/projects/register/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
27+
intersphinx_mapping = {
28+
"python": ("https://docs.python.org/3.4", None),
29+
"BusDevice": (
30+
"https://circuitpython.readthedocs.io/projects/busdevice/en/latest/",
31+
None,
32+
),
33+
"Register": (
34+
"https://circuitpython.readthedocs.io/projects/register/en/latest/",
35+
None,
36+
),
37+
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
38+
}
2739

2840
# Add any paths that contain templates here, relative to this directory.
29-
templates_path = ['_templates']
41+
templates_path = ["_templates"]
3042

31-
source_suffix = '.rst'
43+
source_suffix = ".rst"
3244

3345
# The master toctree document.
34-
master_doc = 'index'
46+
master_doc = "index"
3547

3648
# General information about the project.
37-
project = u'Adafruit MPU6050 Library'
38-
copyright = u'2019 Bryan Siepert'
39-
author = u'Bryan Siepert'
49+
project = u"Adafruit MPU6050 Library"
50+
copyright = u"2019 Bryan Siepert"
51+
author = u"Bryan Siepert"
4052

4153
# The version info for the project you're documenting, acts as replacement for
4254
# |version| and |release|, also used in various other places throughout the
4355
# built documents.
4456
#
4557
# The short X.Y version.
46-
version = u'1.0'
58+
version = u"1.0"
4759
# The full version, including alpha/beta/rc tags.
48-
release = u'1.0'
60+
release = u"1.0"
4961

5062
# The language for content autogenerated by Sphinx. Refer to documentation
5163
# for a list of supported languages.
@@ -57,7 +69,7 @@
5769
# List of patterns, relative to source directory, that match files and
5870
# directories to ignore when looking for source files.
5971
# This patterns also effect to html_static_path and html_extra_path
60-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
72+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
6173

6274
# The reST default role (used for this markup: `text`) to use for all
6375
# documents.
@@ -69,7 +81,7 @@
6981
add_function_parentheses = True
7082

7183
# The name of the Pygments (syntax highlighting) style to use.
72-
pygments_style = 'sphinx'
84+
pygments_style = "sphinx"
7385

7486
# If true, `todo` and `todoList` produce output, else they produce nothing.
7587
todo_include_todos = False
@@ -84,68 +96,76 @@
8496
# The theme to use for HTML and HTML Help pages. See the documentation for
8597
# a list of builtin themes.
8698
#
87-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
99+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
88100

89101
if not on_rtd: # only import and set the theme if we're building docs locally
90102
try:
91103
import sphinx_rtd_theme
92-
html_theme = 'sphinx_rtd_theme'
93-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
104+
105+
html_theme = "sphinx_rtd_theme"
106+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
94107
except:
95-
html_theme = 'default'
96-
html_theme_path = ['.']
108+
html_theme = "default"
109+
html_theme_path = ["."]
97110
else:
98-
html_theme_path = ['.']
111+
html_theme_path = ["."]
99112

100113
# Add any paths that contain custom static files (such as style sheets) here,
101114
# relative to this directory. They are copied after the builtin static files,
102115
# so a file named "default.css" will overwrite the builtin "default.css".
103-
html_static_path = ['_static']
116+
html_static_path = ["_static"]
104117

105118
# The name of an image file (relative to this directory) to use as a favicon of
106119
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
107120
# pixels large.
108121
#
109-
html_favicon = '_static/favicon.ico'
122+
html_favicon = "_static/favicon.ico"
110123

111124
# Output file base name for HTML help builder.
112-
htmlhelp_basename = 'AdafruitMpu6050Librarydoc'
125+
htmlhelp_basename = "AdafruitMpu6050Librarydoc"
113126

114127
# -- Options for LaTeX output ---------------------------------------------
115128

116129
latex_elements = {
117-
# The paper size ('letterpaper' or 'a4paper').
118-
#
119-
# 'papersize': 'letterpaper',
120-
121-
# The font size ('10pt', '11pt' or '12pt').
122-
#
123-
# 'pointsize': '10pt',
124-
125-
# Additional stuff for the LaTeX preamble.
126-
#
127-
# 'preamble': '',
128-
129-
# Latex figure (float) alignment
130-
#
131-
# 'figure_align': 'htbp',
130+
# The paper size ('letterpaper' or 'a4paper').
131+
#
132+
# 'papersize': 'letterpaper',
133+
# The font size ('10pt', '11pt' or '12pt').
134+
#
135+
# 'pointsize': '10pt',
136+
# Additional stuff for the LaTeX preamble.
137+
#
138+
# 'preamble': '',
139+
# Latex figure (float) alignment
140+
#
141+
# 'figure_align': 'htbp',
132142
}
133143

134144
# Grouping the document tree into LaTeX files. List of tuples
135145
# (source start file, target name, title,
136146
# author, documentclass [howto, manual, or own class]).
137147
latex_documents = [
138-
(master_doc, 'AdafruitMPU6050Library.tex', u'AdafruitMPU6050 Library Documentation',
139-
author, 'manual'),
148+
(
149+
master_doc,
150+
"AdafruitMPU6050Library.tex",
151+
u"AdafruitMPU6050 Library Documentation",
152+
author,
153+
"manual",
154+
),
140155
]
141156

142157
# -- Options for manual page output ---------------------------------------
143158

144159
# One entry per manual page. List of tuples
145160
# (source start file, name, description, authors, manual section).
146161
man_pages = [
147-
(master_doc, 'AdafruitMPU6050library', u'Adafruit MPU6050 Library Documentation',
148-
[author], 1)
162+
(
163+
master_doc,
164+
"AdafruitMPU6050library",
165+
u"Adafruit MPU6050 Library Documentation",
166+
[author],
167+
1,
168+
)
149169
]
150170

151171
# -- Options for Texinfo output -------------------------------------------
@@ -154,7 +174,13 @@
154174
# (source start file, target name, title, author,
155175
# dir menu entry, description, category)
156176
texinfo_documents = [
157-
(master_doc, 'AdafruitMPU6050Library', u'Adafruit MPU6050 Library Documentation',
158-
author, 'AdafruitMPU6050Library', 'One line description of project.',
159-
'Miscellaneous'),
177+
(
178+
master_doc,
179+
"AdafruitMPU6050Library",
180+
u"Adafruit MPU6050 Library Documentation",
181+
author,
182+
"AdafruitMPU6050Library",
183+
"One line description of project.",
184+
"Miscellaneous",
185+
),
160186
]

0 commit comments

Comments
 (0)