Skip to content

Commit 7499075

Browse files
authored
Merge pull request #17 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents bce8db2 + 1053887 commit 7499075

File tree

6 files changed

+161
-131
lines changed

6 files changed

+161
-131
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

.pylintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ 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
123+
notes=FIXME,XXX
123124

124125

125126
[TYPECHECK]

adafruit_max31855.py

Lines changed: 66 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
4545
"""
4646
import math
47+
4748
try:
4849
import struct
4950
except ImportError:
@@ -54,6 +55,7 @@
5455
__version__ = "0.0.0-auto.0"
5556
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MAX31855.git"
5657

58+
5759
class MAX31855:
5860
"""
5961
Driver for the MAX31855 thermocouple amplifier.
@@ -65,7 +67,7 @@ def __init__(self, spi, cs):
6567

6668
def _read(self, internal=False):
6769
with self.spi_device as spi:
68-
spi.readinto(self.data) #pylint: disable=no-member
70+
spi.readinto(self.data) # pylint: disable=no-member
6971
if self.data[3] & 0x01:
7072
raise RuntimeError("thermocouple not connected")
7173
if self.data[3] & 0x02:
@@ -74,7 +76,7 @@ def _read(self, internal=False):
7476
raise RuntimeError("short circuit to power")
7577
if self.data[1] & 0x01:
7678
raise RuntimeError("faulty reading")
77-
temp, refer = struct.unpack('>hh', self.data)
79+
temp, refer = struct.unpack(">hh", self.data)
7880
refer >>= 4
7981
temp >>= 2
8082
if internal:
@@ -107,63 +109,76 @@ def temperature_NIST(self):
107109
VOUT = 0.041276 * (TR - TAMB)
108110
# cold junction equivalent thermocouple voltage
109111
if TAMB >= 0:
110-
VREF =(-0.176004136860E-01 +
111-
0.389212049750E-01 * TAMB +
112-
0.185587700320E-04 * math.pow(TAMB, 2) +
113-
-0.994575928740E-07 * math.pow(TAMB, 3) +
114-
0.318409457190E-09 * math.pow(TAMB, 4) +
115-
-0.560728448890E-12 * math.pow(TAMB, 5) +
116-
0.560750590590E-15 * math.pow(TAMB, 6) +
117-
-0.320207200030E-18 * math.pow(TAMB, 7) +
118-
0.971511471520E-22 * math.pow(TAMB, 8) +
119-
-0.121047212750E-25 * math.pow(TAMB, 9) +
120-
0.1185976 * math.exp(-0.1183432E-03 * math.pow(TAMB - 0.1269686E+03, 2)))
112+
VREF = (
113+
-0.176004136860e-01
114+
+ 0.389212049750e-01 * TAMB
115+
+ 0.185587700320e-04 * math.pow(TAMB, 2)
116+
+ -0.994575928740e-07 * math.pow(TAMB, 3)
117+
+ 0.318409457190e-09 * math.pow(TAMB, 4)
118+
+ -0.560728448890e-12 * math.pow(TAMB, 5)
119+
+ 0.560750590590e-15 * math.pow(TAMB, 6)
120+
+ -0.320207200030e-18 * math.pow(TAMB, 7)
121+
+ 0.971511471520e-22 * math.pow(TAMB, 8)
122+
+ -0.121047212750e-25 * math.pow(TAMB, 9)
123+
+ 0.1185976
124+
* math.exp(-0.1183432e-03 * math.pow(TAMB - 0.1269686e03, 2))
125+
)
121126
else:
122-
VREF =( 0.394501280250E-01 * TAMB +
123-
0.236223735980E-04 * math.pow(TAMB, 2) +
124-
-0.328589067840E-06 * math.pow(TAMB, 3) +
125-
-0.499048287770E-08 * math.pow(TAMB, 4) +
126-
-0.675090591730E-10 * math.pow(TAMB, 5) +
127-
-0.574103274280E-12 * math.pow(TAMB, 6) +
128-
-0.310888728940E-14 * math.pow(TAMB, 7) +
129-
-0.104516093650E-16 * math.pow(TAMB, 8) +
130-
-0.198892668780E-19 * math.pow(TAMB, 9) +
131-
-0.163226974860E-22 * math.pow(TAMB, 10))
127+
VREF = (
128+
0.394501280250e-01 * TAMB
129+
+ 0.236223735980e-04 * math.pow(TAMB, 2)
130+
+ -0.328589067840e-06 * math.pow(TAMB, 3)
131+
+ -0.499048287770e-08 * math.pow(TAMB, 4)
132+
+ -0.675090591730e-10 * math.pow(TAMB, 5)
133+
+ -0.574103274280e-12 * math.pow(TAMB, 6)
134+
+ -0.310888728940e-14 * math.pow(TAMB, 7)
135+
+ -0.104516093650e-16 * math.pow(TAMB, 8)
136+
+ -0.198892668780e-19 * math.pow(TAMB, 9)
137+
+ -0.163226974860e-22 * math.pow(TAMB, 10)
138+
)
132139
# total thermoelectric voltage
133140
VTOTAL = VOUT + VREF
134141
# determine coefficients
135142
# https://srdata.nist.gov/its90/type_k/kcoefficients_inverse.html
136-
if -5.891 <= VTOTAL <=0:
137-
DCOEF = (0.0000000E+00,
138-
2.5173462E+01,
139-
-1.1662878E+00,
140-
-1.0833638E+00,
141-
-8.9773540E-01,
142-
-3.7342377E-01,
143-
-8.6632643E-02,
144-
-1.0450598E-02,
145-
-5.1920577E-04)
143+
if -5.891 <= VTOTAL <= 0:
144+
DCOEF = (
145+
0.0000000e00,
146+
2.5173462e01,
147+
-1.1662878e00,
148+
-1.0833638e00,
149+
-8.9773540e-01,
150+
-3.7342377e-01,
151+
-8.6632643e-02,
152+
-1.0450598e-02,
153+
-5.1920577e-04,
154+
)
146155
elif 0 < VTOTAL <= 20.644:
147-
DCOEF = (0.000000E+00,
148-
2.508355E+01,
149-
7.860106E-02,
150-
-2.503131E-01,
151-
8.315270E-02,
152-
-1.228034E-02,
153-
9.804036E-04,
154-
-4.413030E-05,
155-
1.057734E-06,
156-
-1.052755E-08)
156+
DCOEF = (
157+
0.000000e00,
158+
2.508355e01,
159+
7.860106e-02,
160+
-2.503131e-01,
161+
8.315270e-02,
162+
-1.228034e-02,
163+
9.804036e-04,
164+
-4.413030e-05,
165+
1.057734e-06,
166+
-1.052755e-08,
167+
)
157168
elif 20.644 < VTOTAL <= 54.886:
158-
DCOEF = (-1.318058E+02,
159-
4.830222E+01,
160-
-1.646031E+00,
161-
5.464731E-02,
162-
-9.650715E-04,
163-
8.802193E-06,
164-
-3.110810E-08)
169+
DCOEF = (
170+
-1.318058e02,
171+
4.830222e01,
172+
-1.646031e00,
173+
5.464731e-02,
174+
-9.650715e-04,
175+
8.802193e-06,
176+
-3.110810e-08,
177+
)
165178
else:
166-
raise RuntimeError("Total thermoelectric voltage out of range:{}".format(VTOTAL))
179+
raise RuntimeError(
180+
"Total thermoelectric voltage out of range:{}".format(VTOTAL)
181+
)
167182
# compute temperature
168183
TEMPERATURE = 0
169184
for n, c in enumerate(DCOEF):

docs/conf.py

Lines changed: 70 additions & 48 deletions
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.
21-
#autodoc_mock_imports = ["adafruit_bus_device"]
22-
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)}
22+
# autodoc_mock_imports = ["adafruit_bus_device"]
23+
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 MAX31855 Library'
35-
copyright = u'2017 Radomir Dopieralski'
36-
author = u'Radomir Dopieralski'
42+
project = u"Adafruit MAX31855 Library"
43+
copyright = u"2017 Radomir Dopieralski"
44+
author = u"Radomir Dopieralski"
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
@@ -79,68 +87,76 @@
7987
# The theme to use for HTML and HTML Help pages. See the documentation for
8088
# a list of builtin themes.
8189
#
82-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
90+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
8391

8492
if not on_rtd: # only import and set the theme if we're building docs locally
8593
try:
8694
import sphinx_rtd_theme
87-
html_theme = 'sphinx_rtd_theme'
88-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
95+
96+
html_theme = "sphinx_rtd_theme"
97+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
8998
except:
90-
html_theme = 'default'
91-
html_theme_path = ['.']
99+
html_theme = "default"
100+
html_theme_path = ["."]
92101
else:
93-
html_theme_path = ['.']
102+
html_theme_path = ["."]
94103

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

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

106115
# Output file base name for HTML help builder.
107-
htmlhelp_basename = 'AdafruitMAX31855Librarydoc'
116+
htmlhelp_basename = "AdafruitMAX31855Librarydoc"
108117

109118
# -- Options for LaTeX output ---------------------------------------------
110119

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

129135
# Grouping the document tree into LaTeX files. List of tuples
130136
# (source start file, target name, title,
131137
# author, documentclass [howto, manual, or own class]).
132138
latex_documents = [
133-
(master_doc, 'AdafruitMAX31855Library.tex', u'Adafruit MAX31855 Library Documentation',
134-
u'Radomir Dopieralski', 'manual'),
139+
(
140+
master_doc,
141+
"AdafruitMAX31855Library.tex",
142+
u"Adafruit MAX31855 Library Documentation",
143+
u"Radomir Dopieralski",
144+
"manual",
145+
),
135146
]
136147

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

139150
# One entry per manual page. List of tuples
140151
# (source start file, name, description, authors, manual section).
141152
man_pages = [
142-
(master_doc, 'adafruitMAX31855library', u'Adafruit MAX31855 Library Documentation',
143-
[author], 1)
153+
(
154+
master_doc,
155+
"adafruitMAX31855library",
156+
u"Adafruit MAX31855 Library Documentation",
157+
[author],
158+
1,
159+
)
144160
]
145161

146162
# -- Options for Texinfo output -------------------------------------------
@@ -149,7 +165,13 @@
149165
# (source start file, target name, title, author,
150166
# dir menu entry, description, category)
151167
texinfo_documents = [
152-
(master_doc, 'AdafruitMAX31855Library', u'Adafruit MAX31855 Library Documentation',
153-
author, 'AdafruitMAX31855Library', 'One line description of project.',
154-
'Miscellaneous'),
168+
(
169+
master_doc,
170+
"AdafruitMAX31855Library",
171+
u"Adafruit MAX31855 Library Documentation",
172+
author,
173+
"AdafruitMAX31855Library",
174+
"One line description of project.",
175+
"Miscellaneous",
176+
),
155177
]

examples/max31855_simpletest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
while True:
1212
tempC = max31855.temperature
1313
tempF = tempC * 9 / 5 + 32
14-
print('Temperature: {} C {} F '.format(tempC, tempF))
14+
print("Temperature: {} C {} F ".format(tempC, tempF))
1515
time.sleep(2.0)

0 commit comments

Comments
 (0)