Skip to content

Commit 0e8e12d

Browse files
authored
Merge pull request #17 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents f0d1933 + bfc2c06 commit 0e8e12d

File tree

6 files changed

+151
-130
lines changed

6 files changed

+151
-130
lines changed

.github/workflows/build.yml

+1-1
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

.pylintrc

+3-3
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ spelling-store-unknown-words=no
119119
[MISCELLANEOUS]
120120

121121
# List of note tags to take in consideration, separated by a comma.
122-
#notes=FIXME,XXX,TODO
122+
# notes=FIXME,XXX,TODO
123123
notes=FIXME,XXX
124124

125125

@@ -301,7 +301,7 @@ function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
301301

302302
# Good variable names which should always be accepted, separated by a comma
303303
# good-names=i,j,k,ex,Run,_
304-
good-names=r,g,b,i,j,k,n,ex,Run,_
304+
good-names=r,g,b,w,i,j,k,n,x,y,z,ex,ok,Run,_
305305

306306
# Include a hint for the correct naming format with invalid-name
307307
include-naming-hint=no
@@ -423,7 +423,7 @@ max-returns=6
423423
max-statements=50
424424

425425
# Minimum number of public methods for a class (see R0903).
426-
min-public-methods=2
426+
min-public-methods=1
427427

428428

429429
[EXCEPTIONS]

adafruit_fxos8700.py

+46-47
Original file line numberDiff line numberDiff line change
@@ -58,37 +58,37 @@
5858

5959
# Register addresses and other constants:
6060
# pylint: disable=bad-whitespace
61-
_FXOS8700_ADDRESS = const(0x1F) # 0011111
62-
_FXOS8700_ID = const(0xC7) # 1100 0111
63-
_FXOS8700_REGISTER_STATUS = const(0x00)
64-
_FXOS8700_REGISTER_OUT_X_MSB = const(0x01)
65-
_FXOS8700_REGISTER_OUT_X_LSB = const(0x02)
66-
_FXOS8700_REGISTER_OUT_Y_MSB = const(0x03)
67-
_FXOS8700_REGISTER_OUT_Y_LSB = const(0x04)
68-
_FXOS8700_REGISTER_OUT_Z_MSB = const(0x05)
69-
_FXOS8700_REGISTER_OUT_Z_LSB = const(0x06)
70-
_FXOS8700_REGISTER_WHO_AM_I = const(0x0D) # 11000111 r
61+
_FXOS8700_ADDRESS = const(0x1F) # 0011111
62+
_FXOS8700_ID = const(0xC7) # 1100 0111
63+
_FXOS8700_REGISTER_STATUS = const(0x00)
64+
_FXOS8700_REGISTER_OUT_X_MSB = const(0x01)
65+
_FXOS8700_REGISTER_OUT_X_LSB = const(0x02)
66+
_FXOS8700_REGISTER_OUT_Y_MSB = const(0x03)
67+
_FXOS8700_REGISTER_OUT_Y_LSB = const(0x04)
68+
_FXOS8700_REGISTER_OUT_Z_MSB = const(0x05)
69+
_FXOS8700_REGISTER_OUT_Z_LSB = const(0x06)
70+
_FXOS8700_REGISTER_WHO_AM_I = const(0x0D) # 11000111 r
7171
_FXOS8700_REGISTER_XYZ_DATA_CFG = const(0x0E)
72-
_FXOS8700_REGISTER_CTRL_REG1 = const(0x2A) # 00000000 r/w
73-
_FXOS8700_REGISTER_CTRL_REG2 = const(0x2B) # 00000000 r/w
74-
_FXOS8700_REGISTER_CTRL_REG3 = const(0x2C) # 00000000 r/w
75-
_FXOS8700_REGISTER_CTRL_REG4 = const(0x2D) # 00000000 r/w
76-
_FXOS8700_REGISTER_CTRL_REG5 = const(0x2E) # 00000000 r/w
77-
_FXOS8700_REGISTER_MSTATUS = const(0x32)
78-
_FXOS8700_REGISTER_MOUT_X_MSB = const(0x33)
79-
_FXOS8700_REGISTER_MOUT_X_LSB = const(0x34)
80-
_FXOS8700_REGISTER_MOUT_Y_MSB = const(0x35)
81-
_FXOS8700_REGISTER_MOUT_Y_LSB = const(0x36)
82-
_FXOS8700_REGISTER_MOUT_Z_MSB = const(0x37)
83-
_FXOS8700_REGISTER_MOUT_Z_LSB = const(0x38)
84-
_FXOS8700_REGISTER_MCTRL_REG1 = const(0x5B) # 00000000 r/w
85-
_FXOS8700_REGISTER_MCTRL_REG2 = const(0x5C) # 00000000 r/w
86-
_FXOS8700_REGISTER_MCTRL_REG3 = const(0x5D) # 00000000 r/w
87-
_ACCEL_MG_LSB_2G = 0.000244
88-
_ACCEL_MG_LSB_4G = 0.000488
89-
_ACCEL_MG_LSB_8G = 0.000976
90-
_MAG_UT_LSB = 0.1
91-
_SENSORS_GRAVITY_STANDARD = 9.80665
72+
_FXOS8700_REGISTER_CTRL_REG1 = const(0x2A) # 00000000 r/w
73+
_FXOS8700_REGISTER_CTRL_REG2 = const(0x2B) # 00000000 r/w
74+
_FXOS8700_REGISTER_CTRL_REG3 = const(0x2C) # 00000000 r/w
75+
_FXOS8700_REGISTER_CTRL_REG4 = const(0x2D) # 00000000 r/w
76+
_FXOS8700_REGISTER_CTRL_REG5 = const(0x2E) # 00000000 r/w
77+
_FXOS8700_REGISTER_MSTATUS = const(0x32)
78+
_FXOS8700_REGISTER_MOUT_X_MSB = const(0x33)
79+
_FXOS8700_REGISTER_MOUT_X_LSB = const(0x34)
80+
_FXOS8700_REGISTER_MOUT_Y_MSB = const(0x35)
81+
_FXOS8700_REGISTER_MOUT_Y_LSB = const(0x36)
82+
_FXOS8700_REGISTER_MOUT_Z_MSB = const(0x37)
83+
_FXOS8700_REGISTER_MOUT_Z_LSB = const(0x38)
84+
_FXOS8700_REGISTER_MCTRL_REG1 = const(0x5B) # 00000000 r/w
85+
_FXOS8700_REGISTER_MCTRL_REG2 = const(0x5C) # 00000000 r/w
86+
_FXOS8700_REGISTER_MCTRL_REG3 = const(0x5D) # 00000000 r/w
87+
_ACCEL_MG_LSB_2G = 0.000244
88+
_ACCEL_MG_LSB_4G = 0.000488
89+
_ACCEL_MG_LSB_8G = 0.000976
90+
_MAG_UT_LSB = 0.1
91+
_SENSORS_GRAVITY_STANDARD = 9.80665
9292
# pylint: enable=bad-whitespace
9393

9494
# User-facing constants/module-level globals:
@@ -107,19 +107,19 @@ def _twos_comp(val, bits):
107107

108108
class FXOS8700:
109109
"""Driver for the NXP FXOS8700 accelerometer and magnetometer."""
110+
110111
# Class-level buffer for reading and writing data with the sensor.
111112
# This reduces memory allocations but means the code is not re-entrant or
112113
# thread safe!
113114
_BUFFER = bytearray(13)
114115

115-
def __init__(self, i2c, address=_FXOS8700_ADDRESS,
116-
accel_range=ACCEL_RANGE_2G):
116+
def __init__(self, i2c, address=_FXOS8700_ADDRESS, accel_range=ACCEL_RANGE_2G):
117117
assert accel_range in (ACCEL_RANGE_2G, ACCEL_RANGE_4G, ACCEL_RANGE_8G)
118118
self._accel_range = accel_range
119119
self._device = i2c_dev.I2CDevice(i2c, address)
120120
# Check for chip ID value.
121121
if self._read_u8(_FXOS8700_REGISTER_WHO_AM_I) != _FXOS8700_ID:
122-
raise RuntimeError('Failed to find FXOS8700, check wiring!')
122+
raise RuntimeError("Failed to find FXOS8700, check wiring!")
123123
# Set to standby mode (required to make changes to this register)
124124
self._write_u8(_FXOS8700_REGISTER_CTRL_REG1, 0)
125125
if accel_range == ACCEL_RANGE_2G:
@@ -142,8 +142,7 @@ def _read_u8(self, address):
142142
# Read an 8-bit unsigned value from the specified 8-bit address.
143143
with self._device as i2c:
144144
self._BUFFER[0] = address & 0xFF
145-
i2c.write_then_readinto(self._BUFFER, self._BUFFER,
146-
out_end=1, in_end=1)
145+
i2c.write_then_readinto(self._BUFFER, self._BUFFER, out_end=1, in_end=1)
147146
return self._BUFFER[0]
148147

149148
def _write_u8(self, address, val):
@@ -166,11 +165,10 @@ def read_raw_accel_mag(self):
166165
# Read accelerometer data from sensor.
167166
with self._device as i2c:
168167
self._BUFFER[0] = _FXOS8700_REGISTER_OUT_X_MSB
169-
i2c.write_then_readinto(self._BUFFER, self._BUFFER,
170-
out_end=1, in_end=6)
171-
accel_raw_x = struct.unpack_from('>H', self._BUFFER[0:2])[0]
172-
accel_raw_y = struct.unpack_from('>H', self._BUFFER[2:4])[0]
173-
accel_raw_z = struct.unpack_from('>H', self._BUFFER[4:6])[0]
168+
i2c.write_then_readinto(self._BUFFER, self._BUFFER, out_end=1, in_end=6)
169+
accel_raw_x = struct.unpack_from(">H", self._BUFFER[0:2])[0]
170+
accel_raw_y = struct.unpack_from(">H", self._BUFFER[2:4])[0]
171+
accel_raw_z = struct.unpack_from(">H", self._BUFFER[4:6])[0]
174172
# Convert accelerometer data to signed 14-bit value from 16-bit
175173
# left aligned 2's compliment value.
176174
accel_raw_x = _twos_comp(accel_raw_x >> 2, 14)
@@ -180,13 +178,14 @@ def read_raw_accel_mag(self):
180178
# 16-bit signed data so struct parsing can handle it directly.
181179
with self._device as i2c:
182180
self._BUFFER[0] = _FXOS8700_REGISTER_MOUT_X_MSB
183-
i2c.write_then_readinto(self._BUFFER, self._BUFFER,
184-
out_end=1, in_end=6)
185-
mag_raw_x = struct.unpack_from('>h', self._BUFFER[0:2])[0]
186-
mag_raw_y = struct.unpack_from('>h', self._BUFFER[2:4])[0]
187-
mag_raw_z = struct.unpack_from('>h', self._BUFFER[4:6])[0]
188-
return ((accel_raw_x, accel_raw_y, accel_raw_z),
189-
(mag_raw_x, mag_raw_y, mag_raw_z))
181+
i2c.write_then_readinto(self._BUFFER, self._BUFFER, out_end=1, in_end=6)
182+
mag_raw_x = struct.unpack_from(">h", self._BUFFER[0:2])[0]
183+
mag_raw_y = struct.unpack_from(">h", self._BUFFER[2:4])[0]
184+
mag_raw_z = struct.unpack_from(">h", self._BUFFER[4:6])[0]
185+
return (
186+
(accel_raw_x, accel_raw_y, accel_raw_z),
187+
(mag_raw_x, mag_raw_y, mag_raw_z),
188+
)
190189

191190
@property
192191
def accelerometer(self):

docs/conf.py

+68-46
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,55 @@
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.viewcode',
14+
"sphinx.ext.autodoc",
15+
"sphinx.ext.intersphinx",
16+
"sphinx.ext.viewcode",
1617
]
1718

1819
# Uncomment the below if you use native CircuitPython modules such as
1920
# digitalio, micropython and busio. List the modules you use. Without it, the
2021
# autodoc module docs will fail to generate with a warning.
2122
# autodoc_mock_imports = ["adafruit_bus_device", "micropython"]
2223

23-
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
24+
intersphinx_mapping = {
25+
"python": ("https://docs.python.org/3.4", None),
26+
"BusDevice": (
27+
"https://circuitpython.readthedocs.io/projects/busdevice/en/latest/",
28+
None,
29+
),
30+
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
31+
}
2432

2533
# Add any paths that contain templates here, relative to this directory.
26-
templates_path = ['_templates']
34+
templates_path = ["_templates"]
2735

28-
source_suffix = '.rst'
36+
source_suffix = ".rst"
2937

3038
# The master toctree document.
31-
master_doc = 'index'
39+
master_doc = "index"
3240

3341
# General information about the project.
34-
project = u'Adafruit FXOS8700 Library'
35-
copyright = u'2017 Tony DiCola'
36-
author = u'Tony DiCola'
42+
project = u"Adafruit FXOS8700 Library"
43+
copyright = u"2017 Tony DiCola"
44+
author = u"Tony DiCola"
3745

3846
# The version info for the project you're documenting, acts as replacement for
3947
# |version| and |release|, also used in various other places throughout the
4048
# built documents.
4149
#
4250
# The short X.Y version.
43-
version = u'1.0'
51+
version = u"1.0"
4452
# The full version, including alpha/beta/rc tags.
45-
release = u'1.0'
53+
release = u"1.0"
4654

4755
# The language for content autogenerated by Sphinx. Refer to documentation
4856
# for a list of supported languages.
@@ -54,7 +62,7 @@
5462
# List of patterns, relative to source directory, that match files and
5563
# directories to ignore when looking for source files.
5664
# This patterns also effect to html_static_path and html_extra_path
57-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
65+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
5866

5967
# The reST default role (used for this markup: `text`) to use for all
6068
# documents.
@@ -66,7 +74,7 @@
6674
add_function_parentheses = True
6775

6876
# The name of the Pygments (syntax highlighting) style to use.
69-
pygments_style = 'sphinx'
77+
pygments_style = "sphinx"
7078

7179
# If true, `todo` and `todoList` produce output, else they produce nothing.
7280
todo_include_todos = False
@@ -80,68 +88,76 @@
8088
# The theme to use for HTML and HTML Help pages. See the documentation for
8189
# a list of builtin themes.
8290
#
83-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
91+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
8492

8593
if not on_rtd: # only import and set the theme if we're building docs locally
8694
try:
8795
import sphinx_rtd_theme
88-
html_theme = 'sphinx_rtd_theme'
89-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
96+
97+
html_theme = "sphinx_rtd_theme"
98+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
9099
except:
91-
html_theme = 'default'
92-
html_theme_path = ['.']
100+
html_theme = "default"
101+
html_theme_path = ["."]
93102
else:
94-
html_theme_path = ['.']
103+
html_theme_path = ["."]
95104

96105
# Add any paths that contain custom static files (such as style sheets) here,
97106
# relative to this directory. They are copied after the builtin static files,
98107
# so a file named "default.css" will overwrite the builtin "default.css".
99-
html_static_path = ['_static']
108+
html_static_path = ["_static"]
100109

101110
# The name of an image file (relative to this directory) to use as a favicon of
102111
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
103112
# pixels large.
104113
#
105-
html_favicon = '_static/favicon.ico'
114+
html_favicon = "_static/favicon.ico"
106115

107116
# Output file base name for HTML help builder.
108-
htmlhelp_basename = 'AdafruitFXOS8700Librarydoc'
117+
htmlhelp_basename = "AdafruitFXOS8700Librarydoc"
109118

110119
# -- Options for LaTeX output ---------------------------------------------
111120

112121
latex_elements = {
113-
# The paper size ('letterpaper' or 'a4paper').
114-
#
115-
# 'papersize': 'letterpaper',
116-
117-
# The font size ('10pt', '11pt' or '12pt').
118-
#
119-
# 'pointsize': '10pt',
120-
121-
# Additional stuff for the LaTeX preamble.
122-
#
123-
# 'preamble': '',
124-
125-
# Latex figure (float) alignment
126-
#
127-
# 'figure_align': 'htbp',
122+
# The paper size ('letterpaper' or 'a4paper').
123+
#
124+
# 'papersize': 'letterpaper',
125+
# The font size ('10pt', '11pt' or '12pt').
126+
#
127+
# 'pointsize': '10pt',
128+
# Additional stuff for the LaTeX preamble.
129+
#
130+
# 'preamble': '',
131+
# Latex figure (float) alignment
132+
#
133+
# 'figure_align': 'htbp',
128134
}
129135

130136
# Grouping the document tree into LaTeX files. List of tuples
131137
# (source start file, target name, title,
132138
# author, documentclass [howto, manual, or own class]).
133139
latex_documents = [
134-
(master_doc, 'AdafruitFXOS8700Library.tex', u'Adafruit FXOS8700 Library Documentation',
135-
author, 'manual'),
140+
(
141+
master_doc,
142+
"AdafruitFXOS8700Library.tex",
143+
u"Adafruit FXOS8700 Library Documentation",
144+
author,
145+
"manual",
146+
),
136147
]
137148

138149
# -- Options for manual page output ---------------------------------------
139150

140151
# One entry per manual page. List of tuples
141152
# (source start file, name, description, authors, manual section).
142153
man_pages = [
143-
(master_doc, 'adafruitFXOS8700library', u'Adafruit FXOS8700 Library Documentation',
144-
[author], 1)
154+
(
155+
master_doc,
156+
"adafruitFXOS8700library",
157+
u"Adafruit FXOS8700 Library Documentation",
158+
[author],
159+
1,
160+
)
145161
]
146162

147163
# -- Options for Texinfo output -------------------------------------------
@@ -150,7 +166,13 @@
150166
# (source start file, target name, title, author,
151167
# dir menu entry, description, category)
152168
texinfo_documents = [
153-
(master_doc, 'AdafruitFXOS8700Library', u'Adafruit FXOS8700 Library Documentation',
154-
author, 'AdafruitFXOS8700Library', 'One line description of project.',
155-
'Miscellaneous'),
169+
(
170+
master_doc,
171+
"AdafruitFXOS8700Library",
172+
u"Adafruit FXOS8700 Library Documentation",
173+
author,
174+
"AdafruitFXOS8700Library",
175+
"One line description of project.",
176+
"Miscellaneous",
177+
),
156178
]

0 commit comments

Comments
 (0)