Skip to content

Commit 6821e27

Browse files
authored
Merge pull request #10 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents b55c112 + fb3f86a commit 6821e27

File tree

6 files changed

+137
-99
lines changed

6 files changed

+137
-99
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_max31856.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
from time import sleep
4848
from micropython import const
4949
from adafruit_bus_device.spi_device import SPIDevice
50+
5051
try:
5152
from struct import unpack
5253
except ImportError:
@@ -92,7 +93,7 @@
9293
_MAX31856_FAULT_OPEN = const(0x01)
9394

9495

95-
class ThermocoupleType: # pylint: disable=too-few-public-methods
96+
class ThermocoupleType: # pylint: disable=too-few-public-methods
9697
"""An enum-like class representing the different types of thermocouples that the MAX31856 can
9798
use. The values can be referenced like ``ThermocoupleType.K`` or ``ThermocoupleType.S``
9899
Possible values are
@@ -107,6 +108,7 @@ class ThermocoupleType: # pylint: disable=too-few-public-methods
107108
- ``ThermocoupleType.T``
108109
109110
"""
111+
110112
# pylint: disable=invalid-name
111113
B = 0b0000
112114
E = 0b0001
@@ -156,13 +158,15 @@ def temperature(self):
156158
self._perform_one_shot_measurement()
157159

158160
# unpack the 3-byte temperature as 4 bytes
159-
raw_temp = unpack(">i", self._read_register(_MAX31856_LTCBH_REG, 3)+bytes([0]))[0]
161+
raw_temp = unpack(
162+
">i", self._read_register(_MAX31856_LTCBH_REG, 3) + bytes([0])
163+
)[0]
160164

161165
# shift to remove extra byte from unpack needing 4 bytes
162166
raw_temp >>= 8
163167

164168
# effectively shift raw_read >> 12 to convert pseudo-float
165-
temp_float = (raw_temp / 4096.0)
169+
temp_float = raw_temp / 4096.0
166170

167171
return temp_float
168172

@@ -202,16 +206,17 @@ def temperature_thresholds(self, val):
202206
self._write_u8(_MAX31856_LTLFTL_REG, int_low)
203207

204208
@property
205-
def reference_temperature_thresholds(self): # pylint: disable=invalid-name
209+
def reference_temperature_thresholds(self): # pylint: disable=invalid-name
206210
"""The cold junction's low and high temperature thresholds
207211
as a ``(low_temp, high_temp)`` tuple
208212
"""
209-
return (float(unpack("b", self._read_register(_MAX31856_CJLF_REG, 1))[0]),
210-
float(unpack("b", self._read_register(_MAX31856_CJHF_REG, 1))[0]))
211-
213+
return (
214+
float(unpack("b", self._read_register(_MAX31856_CJLF_REG, 1))[0]),
215+
float(unpack("b", self._read_register(_MAX31856_CJHF_REG, 1))[0]),
216+
)
212217

213218
@reference_temperature_thresholds.setter
214-
def reference_temperature_thresholds(self, val): # pylint: disable=invalid-name
219+
def reference_temperature_thresholds(self, val): # pylint: disable=invalid-name
215220

216221
self._write_u8(_MAX31856_CJLF_REG, int(val[0]))
217222
self._write_u8(_MAX31856_CJHF_REG, int(val[1]))
@@ -245,7 +250,7 @@ def fault(self):
245250
"tc_high": bool(faults & _MAX31856_FAULT_TCHIGH),
246251
"tc_low": bool(faults & _MAX31856_FAULT_TCLOW),
247252
"voltage": bool(faults & _MAX31856_FAULT_OVUV),
248-
"open_tc": bool(faults & _MAX31856_FAULT_OPEN)
253+
"open_tc": bool(faults & _MAX31856_FAULT_OPEN),
249254
}
250255

251256
def _perform_one_shot_measurement(self):
@@ -278,4 +283,4 @@ def _write_u8(self, address, val):
278283
with self._device as device:
279284
self._BUFFER[0] = (address | 0x80) & 0xFF
280285
self._BUFFER[1] = val & 0xFF
281-
device.write(self._BUFFER, end=2) # pylint: disable=no-member
286+
device.write(self._BUFFER, end=2) # pylint: disable=no-member

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", "micropython", "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 MAX31856 Library'
38-
copyright = u'2018 Bryan Siepert'
39-
author = u'Bryan Siepert'
49+
project = u"Adafruit MAX31856 Library"
50+
copyright = u"2018 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 = 'AdafruitMax31856Librarydoc'
125+
htmlhelp_basename = "AdafruitMax31856Librarydoc"
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, 'AdafruitMAX31856Library.tex', u'AdafruitMAX31856 Library Documentation',
139-
author, 'manual'),
148+
(
149+
master_doc,
150+
"AdafruitMAX31856Library.tex",
151+
u"AdafruitMAX31856 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, 'AdafruitMAX31856library', u'Adafruit MAX31856 Library Documentation',
148-
[author], 1)
162+
(
163+
master_doc,
164+
"AdafruitMAX31856library",
165+
u"Adafruit MAX31856 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, 'AdafruitMAX31856Library', u'Adafruit MAX31856 Library Documentation',
158-
author, 'AdafruitMAX31856Library', 'One line description of project.',
159-
'Miscellaneous'),
177+
(
178+
master_doc,
179+
"AdafruitMAX31856Library",
180+
u"Adafruit MAX31856 Library Documentation",
181+
author,
182+
"AdafruitMAX31856Library",
183+
"One line description of project.",
184+
"Miscellaneous",
185+
),
160186
]

examples/max31856_simpletest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import busio
33
import digitalio
44
import adafruit_max31856
5+
56
# create a spi object
67
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
78

@@ -10,7 +11,7 @@
1011
cs.direction = digitalio.Direction.OUTPUT
1112

1213
# create a thermocouple object with the above
13-
thermocouple = adafruit_max31856.MAX31856(spi,cs)
14+
thermocouple = adafruit_max31856.MAX31856(spi, cs)
1415

1516
# print the temperature!
1617
print(thermocouple.temperature)

examples/max31856_thresholds_and_faults.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import busio
44
import digitalio
55
import adafruit_max31856
6+
67
# create a spi object
78
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
89

@@ -24,19 +25,32 @@
2425
current_temp_thresholds = thermocouple.temperature_thresholds
2526
current_cj_thresholds = thermocouple.reference_temperature_thresholds
2627
current_faults = thermocouple.fault
27-
print("Temps: %.2f :: cj: %.2f"%(thermocouple.temperature,
28-
thermocouple.reference_temperature))
28+
print(
29+
"Temps: %.2f :: cj: %.2f"
30+
% (thermocouple.temperature, thermocouple.reference_temperature)
31+
)
2932
print("Thresholds:")
30-
print("Temp low: %.2f high: %.2f"%current_temp_thresholds)
31-
print("CJ low: %.2f high: %.2f"%current_cj_thresholds)
33+
print("Temp low: %.2f high: %.2f" % current_temp_thresholds)
34+
print("CJ low: %.2f high: %.2f" % current_cj_thresholds)
3235
print("")
3336
print("Faults:")
34-
print("Temp Hi: %s | CJ Hi: %s"%(current_faults['tc_high'], current_faults['cj_high']))
35-
print("Temp Low: %s | CJ Low: %s"%(current_faults['tc_low'], current_faults['cj_low']))
36-
print("Temp Range: %s | CJ Range: %s"%(current_faults['tc_range'], current_faults['cj_range']))
37+
print(
38+
"Temp Hi: %s | CJ Hi: %s"
39+
% (current_faults["tc_high"], current_faults["cj_high"])
40+
)
41+
print(
42+
"Temp Low: %s | CJ Low: %s"
43+
% (current_faults["tc_low"], current_faults["cj_low"])
44+
)
45+
print(
46+
"Temp Range: %s | CJ Range: %s"
47+
% (current_faults["tc_range"], current_faults["cj_range"])
48+
)
3749
print("")
38-
print("Open Circuit: %s Voltage Over/Under: %s"%(current_faults['open_tc'],
39-
current_faults['voltage']))
50+
print(
51+
"Open Circuit: %s Voltage Over/Under: %s"
52+
% (current_faults["open_tc"], current_faults["voltage"])
53+
)
4054
print("")
4155

4256
time.sleep(1.0)

0 commit comments

Comments
 (0)