Skip to content

Commit 2de0c7b

Browse files
committed
Ran black, updated to pylint 2.x
1 parent f2ceb3f commit 2de0c7b

File tree

5 files changed

+132
-118
lines changed

5 files changed

+132
-118
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_mcp9600.py

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -142,27 +142,27 @@ class MCP9600:
142142
_alert_2_mode = RWBit(0x9, 1)
143143
_alert_2_enable = RWBit(0x9, 0)
144144
# Alert 3 Configuration - 0xa
145-
_alert_3_interrupt_clear = RWBit(0xa, 7)
146-
_alert_3_monitor = RWBit(0xa, 4)
147-
_alert_3_temp_direction = RWBit(0xa, 3)
148-
_alert_3_state = RWBit(0xa, 2)
149-
_alert_3_mode = RWBit(0xa, 1)
150-
_alert_3_enable = RWBit(0xa, 0)
145+
_alert_3_interrupt_clear = RWBit(0xA, 7)
146+
_alert_3_monitor = RWBit(0xA, 4)
147+
_alert_3_temp_direction = RWBit(0xA, 3)
148+
_alert_3_state = RWBit(0xA, 2)
149+
_alert_3_mode = RWBit(0xA, 1)
150+
_alert_3_enable = RWBit(0xA, 0)
151151
# Alert 4 Configuration - 0xb
152-
_alert_4_interrupt_clear = RWBit(0xb, 7)
153-
_alert_4_monitor = RWBit(0xb, 4)
154-
_alert_4_temp_direction = RWBit(0xb, 3)
155-
_alert_4_state = RWBit(0xb, 2)
156-
_alert_4_mode = RWBit(0xb, 1)
157-
_alert_4_enable = RWBit(0xb, 0)
152+
_alert_4_interrupt_clear = RWBit(0xB, 7)
153+
_alert_4_monitor = RWBit(0xB, 4)
154+
_alert_4_temp_direction = RWBit(0xB, 3)
155+
_alert_4_state = RWBit(0xB, 2)
156+
_alert_4_mode = RWBit(0xB, 1)
157+
_alert_4_enable = RWBit(0xB, 0)
158158
# Alert 1 Hysteresis - 0xc
159-
_alert_1_hysteresis = UnaryStruct(0xc, ">H")
159+
_alert_1_hysteresis = UnaryStruct(0xC, ">H")
160160
# Alert 2 Hysteresis - 0xd
161-
_alert_2_hysteresis = UnaryStruct(0xd, ">H")
161+
_alert_2_hysteresis = UnaryStruct(0xD, ">H")
162162
# Alert 3 Hysteresis - 0xe
163-
_alert_3_hysteresis = UnaryStruct(0xe, ">H")
163+
_alert_3_hysteresis = UnaryStruct(0xE, ">H")
164164
# Alert 4 Hysteresis - 0xf
165-
_alert_4_hysteresis = UnaryStruct(0xf, ">H")
165+
_alert_4_hysteresis = UnaryStruct(0xF, ">H")
166166
# Alert 1 Limit - 0x10
167167
_alert_1_temperature_limit = UnaryStruct(0x10, ">H")
168168
# Alert 2 Limit - 0x11
@@ -196,8 +196,17 @@ def __init__(self, i2c, address=_DEFAULT_ADDRESS, tctype="K", tcfilter=0):
196196
if self._device_id != 0x40:
197197
raise RuntimeError("Failed to find MCP9600 - check wiring!")
198198

199-
def alert_config(self, *, alert_number, alert_temp_source, alert_temp_limit, alert_hysteresis,
200-
alert_temp_direction, alert_mode, alert_state):
199+
def alert_config(
200+
self,
201+
*,
202+
alert_number,
203+
alert_temp_source,
204+
alert_temp_limit,
205+
alert_hysteresis,
206+
alert_temp_direction,
207+
alert_mode,
208+
alert_state
209+
):
201210
"""Configure a specified alert pin. Alert is enabled by default when alert is configured.
202211
To disable an alert pin, use ``alert_disable``.
203212
@@ -250,13 +259,17 @@ def alert_config(self, *, alert_number, alert_temp_source, alert_temp_limit, ale
250259
raise ValueError("Alert pin number must be 1-4.")
251260
if not 0 <= alert_hysteresis < 256:
252261
raise ValueError("Hysteresis value must be 0-255.")
253-
setattr(self, '_alert_%d_monitor' % alert_number, alert_temp_source)
254-
setattr(self, '_alert_%d_temperature_limit' % alert_number, int(alert_temp_limit / 0.0625))
255-
setattr(self, '_alert_%d_hysteresis' % alert_number, alert_hysteresis)
256-
setattr(self, '_alert_%d_temp_direction' % alert_number, alert_temp_direction)
257-
setattr(self, '_alert_%d_mode' % alert_number, alert_mode)
258-
setattr(self, '_alert_%d_state' % alert_number, alert_state)
259-
setattr(self, '_alert_%d_enable' % alert_number, True)
262+
setattr(self, "_alert_%d_monitor" % alert_number, alert_temp_source)
263+
setattr(
264+
self,
265+
"_alert_%d_temperature_limit" % alert_number,
266+
int(alert_temp_limit / 0.0625),
267+
)
268+
setattr(self, "_alert_%d_hysteresis" % alert_number, alert_hysteresis)
269+
setattr(self, "_alert_%d_temp_direction" % alert_number, alert_temp_direction)
270+
setattr(self, "_alert_%d_mode" % alert_number, alert_mode)
271+
setattr(self, "_alert_%d_state" % alert_number, alert_state)
272+
setattr(self, "_alert_%d_enable" % alert_number, True)
260273

261274
def alert_disable(self, alert_number):
262275
"""Configuring an alert using ``alert_config()`` enables the specified alert by default.
@@ -267,7 +280,7 @@ def alert_disable(self, alert_number):
267280
"""
268281
if alert_number not in (1, 2, 3, 4):
269282
raise ValueError("Alert pin number must be 1-4.")
270-
setattr(self, '_alert_%d_enable' % alert_number, False)
283+
setattr(self, "_alert_%d_enable" % alert_number, False)
271284

272285
def alert_interrupt_clear(self, alert_number, interrupt_clear=True):
273286
"""Turns off the alert flag in the MCP9600, and clears the pin state (not used if the alert
@@ -279,7 +292,7 @@ def alert_interrupt_clear(self, alert_number, interrupt_clear=True):
279292
"""
280293
if alert_number not in (1, 2, 3, 4):
281294
raise ValueError("Alert pin number must be 1-4.")
282-
setattr(self, '_alert_%d_interrupt_clear' % alert_number, interrupt_clear)
295+
setattr(self, "_alert_%d_interrupt_clear" % alert_number, interrupt_clear)
283296

284297
@property
285298
def version(self):
@@ -317,10 +330,5 @@ def delta_temperature(self):
317330
def _read_register(self, reg, count=1):
318331
self.buf[0] = reg
319332
with self.i2c_device as i2c:
320-
i2c.write_then_readinto(
321-
self.buf,
322-
self.buf,
323-
out_end=count,
324-
in_start=1
325-
)
333+
i2c.write_then_readinto(self.buf, self.buf, out_end=count, in_start=1)
326334
return self.buf

docs/conf.py

Lines changed: 65 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,32 @@
2324
autodoc_mock_imports = ["adafruit_register"]
2425

2526

26-
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
27+
intersphinx_mapping = {
28+
"python": ("https://docs.python.org/3.4", None),
29+
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
30+
}
2731

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

31-
source_suffix = '.rst'
35+
source_suffix = ".rst"
3236

3337
# The master toctree document.
34-
master_doc = 'index'
38+
master_doc = "index"
3539

3640
# General information about the project.
37-
project = u'Adafruit MCP9600 Library'
38-
copyright = u'2019 Dan Cogliano'
39-
author = u'Dan Cogliano'
41+
project = u"Adafruit MCP9600 Library"
42+
copyright = u"2019 Dan Cogliano"
43+
author = u"Dan Cogliano"
4044

4145
# The version info for the project you're documenting, acts as replacement for
4246
# |version| and |release|, also used in various other places throughout the
4347
# built documents.
4448
#
4549
# The short X.Y version.
46-
version = u'1.0'
50+
version = u"1.0"
4751
# The full version, including alpha/beta/rc tags.
48-
release = u'1.0'
52+
release = u"1.0"
4953

5054
# The language for content autogenerated by Sphinx. Refer to documentation
5155
# for a list of supported languages.
@@ -57,7 +61,7 @@
5761
# List of patterns, relative to source directory, that match files and
5862
# directories to ignore when looking for source files.
5963
# 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']
64+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
6165

6266
# The reST default role (used for this markup: `text`) to use for all
6367
# documents.
@@ -69,7 +73,7 @@
6973
add_function_parentheses = True
7074

7175
# The name of the Pygments (syntax highlighting) style to use.
72-
pygments_style = 'sphinx'
76+
pygments_style = "sphinx"
7377

7478
# If true, `todo` and `todoList` produce output, else they produce nothing.
7579
todo_include_todos = False
@@ -84,68 +88,76 @@
8488
# The theme to use for HTML and HTML Help pages. See the documentation for
8589
# a list of builtin themes.
8690
#
87-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
91+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
8892

8993
if not on_rtd: # only import and set the theme if we're building docs locally
9094
try:
9195
import sphinx_rtd_theme
92-
html_theme = 'sphinx_rtd_theme'
93-
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(), "."]
9499
except:
95-
html_theme = 'default'
96-
html_theme_path = ['.']
100+
html_theme = "default"
101+
html_theme_path = ["."]
97102
else:
98-
html_theme_path = ['.']
103+
html_theme_path = ["."]
99104

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

105110
# The name of an image file (relative to this directory) to use as a favicon of
106111
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
107112
# pixels large.
108113
#
109-
html_favicon = '_static/favicon.ico'
114+
html_favicon = "_static/favicon.ico"
110115

111116
# Output file base name for HTML help builder.
112-
htmlhelp_basename = 'AdafruitMcp9600Librarydoc'
117+
htmlhelp_basename = "AdafruitMcp9600Librarydoc"
113118

114119
# -- Options for LaTeX output ---------------------------------------------
115120

116121
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',
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',
132134
}
133135

134136
# Grouping the document tree into LaTeX files. List of tuples
135137
# (source start file, target name, title,
136138
# author, documentclass [howto, manual, or own class]).
137139
latex_documents = [
138-
(master_doc, 'AdafruitMCP9600Library.tex', u'AdafruitMCP9600 Library Documentation',
139-
author, 'manual'),
140+
(
141+
master_doc,
142+
"AdafruitMCP9600Library.tex",
143+
u"AdafruitMCP9600 Library Documentation",
144+
author,
145+
"manual",
146+
),
140147
]
141148

142149
# -- Options for manual page output ---------------------------------------
143150

144151
# One entry per manual page. List of tuples
145152
# (source start file, name, description, authors, manual section).
146153
man_pages = [
147-
(master_doc, 'AdafruitMCP9600library', u'Adafruit MCP9600 Library Documentation',
148-
[author], 1)
154+
(
155+
master_doc,
156+
"AdafruitMCP9600library",
157+
u"Adafruit MCP9600 Library Documentation",
158+
[author],
159+
1,
160+
)
149161
]
150162

151163
# -- Options for Texinfo output -------------------------------------------
@@ -154,7 +166,13 @@
154166
# (source start file, target name, title, author,
155167
# dir menu entry, description, category)
156168
texinfo_documents = [
157-
(master_doc, 'AdafruitMCP9600Library', u'Adafruit MCP9600 Library Documentation',
158-
author, 'AdafruitMCP9600Library', 'One line description of project.',
159-
'Miscellaneous'),
169+
(
170+
master_doc,
171+
"AdafruitMCP9600Library",
172+
u"Adafruit MCP9600 Library Documentation",
173+
author,
174+
"AdafruitMCP9600Library",
175+
"One line description of project.",
176+
"Miscellaneous",
177+
),
160178
]

examples/mcp9600_simpletest.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,5 @@
99
mcp = adafruit_mcp9600.MCP9600(i2c)
1010

1111
while True:
12-
print((
13-
mcp.ambient_temperature,
14-
mcp.temperature,
15-
mcp.delta_temperature
16-
))
12+
print((mcp.ambient_temperature, mcp.temperature, mcp.delta_temperature))
1713
time.sleep(1)

0 commit comments

Comments
 (0)