Skip to content

Commit 7648851

Browse files
authored
Merge pull request #15 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents d95a20e + fd96579 commit 7648851

File tree

4 files changed

+125
-107
lines changed

4 files changed

+125
-107
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_mlx90393.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"""
4747

4848
import time
49+
4950
try:
5051
import struct
5152
except ImportError:
@@ -57,19 +58,19 @@
5758
__version__ = "0.0.0-auto.0"
5859
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MLX90393.git"
5960

60-
_CMD_SB = const(0b00010000) # Start burst mode
61-
_CMD_SW = const(0b00100000) # Start wakeup on change mode
62-
_CMD_SM = const(0b00110000) # Start single-measurement mode
63-
_CMD_RM = const(0b01000000) # Read measurement
64-
_CMD_RR = const(0b01010000) # Read register
65-
_CMD_WR = const(0b01100000) # Write register
66-
_CMD_EX = const(0b10000000) # Exit mode
67-
_CMD_HR = const(0b11010000) # Memory recall
68-
_CMD_HS = const(0b11100000) # Memory store
69-
_CMD_RT = const(0b11110000) # Reset
70-
_CMD_NOP = const(0x00) # NOP
61+
_CMD_SB = const(0b00010000) # Start burst mode
62+
_CMD_SW = const(0b00100000) # Start wakeup on change mode
63+
_CMD_SM = const(0b00110000) # Start single-measurement mode
64+
_CMD_RM = const(0b01000000) # Read measurement
65+
_CMD_RR = const(0b01010000) # Read register
66+
_CMD_WR = const(0b01100000) # Write register
67+
_CMD_EX = const(0b10000000) # Exit mode
68+
_CMD_HR = const(0b11010000) # Memory recall
69+
_CMD_HS = const(0b11100000) # Memory store
70+
_CMD_RT = const(0b11110000) # Reset
71+
_CMD_NOP = const(0x00) # NOP
7172

72-
_CMD_AXIS_ALL = const(0xE) # X+Y+Z axis bits for commands
73+
_CMD_AXIS_ALL = const(0xE) # X+Y+Z axis bits for commands
7374

7475
_CMD_REG_CONF1 = const(0x00) # Gain
7576
_CMD_REG_CONF2 = const(0x01) # Burst, comm mode
@@ -86,13 +87,13 @@
8687
GAIN_1X = 0x7
8788
_GAIN_SHIFT = const(4)
8889

89-
_RES_2_15 = const(0) # +/- 2^15
90+
_RES_2_15 = const(0) # +/- 2^15
9091
_RES_2_15B = const(1) # +/- 2^15
9192
_RES_22000 = const(2) # +/- 22000
9293
_RES_11000 = const(3) # +/- 11000
9394
_RES_SHIFT = const(5)
9495

95-
_HALLCONF = const(0x0C) # Hall plate spinning rate adjust.
96+
_HALLCONF = const(0x0C) # Hall plate spinning rate adjust.
9697

9798
STATUS_OK = 0x3
9899

@@ -116,7 +117,7 @@
116117
# 1.333x gain: res0(xy)(z), res1(xy)(z), res2(xy)(z), res3(xy)(z)
117118
((0.200, 0.323), (0.401, 0.645), (0.801, 1.291), (1.602, 2.581)),
118119
# 1x gain: res0(xy)(z), res1(xy)(z), res2(xy)(z), res3(xy)(z)
119-
((0.150, 0.242), (0.300, 0.484), (0.601, 0.968), (1.202, 1.936))
120+
((0.150, 0.242), (0.300, 0.484), (0.601, 0.968), (1.202, 1.936)),
120121
)
121122

122123

@@ -143,7 +144,6 @@ def __init__(self, i2c_bus, address=0x0C, gain=GAIN_1X, debug=False):
143144
# Set gain to the supplied level
144145
self.gain = self._gain_current
145146

146-
147147
def _transceive(self, payload, rxlen=0):
148148
"""
149149
Writes the specified 'payload' to the sensor
@@ -152,7 +152,7 @@ def _transceive(self, payload, rxlen=0):
152152
:param rxlen: (optional) The numbers of bytes to read back (default=0)
153153
"""
154154
# Read the response (+1 to account for the mandatory status byte!)
155-
data = bytearray(rxlen+1)
155+
data = bytearray(rxlen + 1)
156156

157157
if len(payload) == 1:
158158
# Transceive with repeated start
@@ -185,23 +185,20 @@ def _transceive(self, payload, rxlen=0):
185185
print("\t Status :", hex(data[0]))
186186
return data
187187

188-
189188
@property
190189
def last_status(self):
191190
"""
192191
Returns the last status byte received from the sensor.
193192
"""
194193
return self._status_last
195194

196-
197195
@property
198196
def gain(self):
199197
"""
200198
Gets the current gain setting for the device.
201199
"""
202200
return self._gain_current
203201

204-
205202
@gain.setter
206203
def gain(self, value):
207204
"""
@@ -212,11 +209,16 @@ def gain(self, value):
212209
if self._debug:
213210
print("\tSetting gain: {}".format(value))
214211
self._gain_current = value
215-
self._transceive(bytes([_CMD_WR,
216-
0x00,
217-
self._gain_current << _GAIN_SHIFT | _HALLCONF,
218-
(_CMD_REG_CONF1 & 0x3F) << 2]))
219-
212+
self._transceive(
213+
bytes(
214+
[
215+
_CMD_WR,
216+
0x00,
217+
self._gain_current << _GAIN_SHIFT | _HALLCONF,
218+
(_CMD_REG_CONF1 & 0x3F) << 2,
219+
]
220+
)
221+
)
220222

221223
def display_status(self):
222224
"""
@@ -235,7 +237,6 @@ def display_status(self):
235237
print("Reset status :", (self._status_last & (1 << 2)) > 0)
236238
print("Response bytes available :", avail)
237239

238-
239240
def read_reg(self, reg):
240241
"""
241242
Gets the current value of the specified register.
@@ -258,7 +259,6 @@ def read_reg(self, reg):
258259
print("\t Status :", hex(data[0]))
259260
return val
260261

261-
262262
def reset(self):
263263
"""
264264
Performs a software reset of the sensor.
@@ -274,12 +274,13 @@ def reset(self):
274274
pass
275275
return self._status_last
276276

277-
278277
@property
279-
def read_data(self, delay=0.01):
278+
def read_data(self):
280279
"""
281280
Reads a single X/Y/Z sample from the magnetometer.
282281
"""
282+
delay = 0.01
283+
283284
# Set the device to single measurement mode
284285
self._transceive(bytes([_CMD_SM | _CMD_AXIS_ALL]))
285286

@@ -293,7 +294,6 @@ def read_data(self, delay=0.01):
293294
# Return the raw int values if requested
294295
return (m_x, m_y, m_z)
295296

296-
297297
@property
298298
def magnetic(self):
299299
"""

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 = ["digitalio", "busio"]
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_CircuitPython_MLX90393 Library'
38-
copyright = u'2018 Kevin Townsend'
39-
author = u'Kevin Townsend'
49+
project = u"Adafruit_CircuitPython_MLX90393 Library"
50+
copyright = u"2018 Kevin Townsend"
51+
author = u"Kevin Townsend"
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 = 'Adafruit_circuitpython_mlx90393Librarydoc'
125+
htmlhelp_basename = "Adafruit_circuitpython_mlx90393Librarydoc"
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, 'Adafruit_CircuitPython_MLX90393Library.tex', u'Adafruit_CircuitPython_MLX90393 Library Documentation',
139-
author, 'manual'),
148+
(
149+
master_doc,
150+
"Adafruit_CircuitPython_MLX90393Library.tex",
151+
u"Adafruit_CircuitPython_MLX90393 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, 'Adafruit_CircuitPython_MLX90393library', u'Adafruit_CircuitPython_MLX90393 Library Documentation',
148-
[author], 1)
162+
(
163+
master_doc,
164+
"Adafruit_CircuitPython_MLX90393library",
165+
u"Adafruit_CircuitPython_MLX90393 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, 'Adafruit_CircuitPython_MLX90393Library', u' Adafruit_CircuitPython_MLX90393 Library Documentation',
158-
author, 'Adafruit_CircuitPython_MLX90393Library', 'One line description of project.',
159-
'Miscellaneous'),
177+
(
178+
master_doc,
179+
"Adafruit_CircuitPython_MLX90393Library",
180+
u" Adafruit_CircuitPython_MLX90393 Library Documentation",
181+
author,
182+
"Adafruit_CircuitPython_MLX90393Library",
183+
"One line description of project.",
184+
"Miscellaneous",
185+
),
160186
]

0 commit comments

Comments
 (0)