Skip to content

Commit 1809692

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

File tree

6 files changed

+133
-117
lines changed

6 files changed

+133
-117
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: 3 additions & 3 deletions
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_max31865.py

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -58,34 +58,34 @@
5858
__version__ = "0.0.0-auto.0"
5959
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MAX31865.git"
6060

61-
#pylint: disable=bad-whitespace
61+
# pylint: disable=bad-whitespace
6262
# Register and other constant values:
63-
_MAX31865_CONFIG_REG = const(0x00)
64-
_MAX31865_CONFIG_BIAS = const(0x80)
65-
_MAX31865_CONFIG_MODEAUTO = const(0x40)
66-
_MAX31865_CONFIG_MODEOFF = const(0x00)
67-
_MAX31865_CONFIG_1SHOT = const(0x20)
68-
_MAX31865_CONFIG_3WIRE = const(0x10)
69-
_MAX31865_CONFIG_24WIRE = const(0x00)
70-
_MAX31865_CONFIG_FAULTSTAT = const(0x02)
71-
_MAX31865_CONFIG_FILT50HZ = const(0x01)
72-
_MAX31865_CONFIG_FILT60HZ = const(0x00)
73-
_MAX31865_RTDMSB_REG = const(0x01)
74-
_MAX31865_RTDLSB_REG = const(0x02)
75-
_MAX31865_HFAULTMSB_REG = const(0x03)
76-
_MAX31865_HFAULTLSB_REG = const(0x04)
77-
_MAX31865_LFAULTMSB_REG = const(0x05)
78-
_MAX31865_LFAULTLSB_REG = const(0x06)
79-
_MAX31865_FAULTSTAT_REG = const(0x07)
80-
_MAX31865_FAULT_HIGHTHRESH = const(0x80)
81-
_MAX31865_FAULT_LOWTHRESH = const(0x40)
82-
_MAX31865_FAULT_REFINLOW = const(0x20)
83-
_MAX31865_FAULT_REFINHIGH = const(0x10)
84-
_MAX31865_FAULT_RTDINLOW = const(0x08)
85-
_MAX31865_FAULT_OVUV = const(0x04)
63+
_MAX31865_CONFIG_REG = const(0x00)
64+
_MAX31865_CONFIG_BIAS = const(0x80)
65+
_MAX31865_CONFIG_MODEAUTO = const(0x40)
66+
_MAX31865_CONFIG_MODEOFF = const(0x00)
67+
_MAX31865_CONFIG_1SHOT = const(0x20)
68+
_MAX31865_CONFIG_3WIRE = const(0x10)
69+
_MAX31865_CONFIG_24WIRE = const(0x00)
70+
_MAX31865_CONFIG_FAULTSTAT = const(0x02)
71+
_MAX31865_CONFIG_FILT50HZ = const(0x01)
72+
_MAX31865_CONFIG_FILT60HZ = const(0x00)
73+
_MAX31865_RTDMSB_REG = const(0x01)
74+
_MAX31865_RTDLSB_REG = const(0x02)
75+
_MAX31865_HFAULTMSB_REG = const(0x03)
76+
_MAX31865_HFAULTLSB_REG = const(0x04)
77+
_MAX31865_LFAULTMSB_REG = const(0x05)
78+
_MAX31865_LFAULTLSB_REG = const(0x06)
79+
_MAX31865_FAULTSTAT_REG = const(0x07)
80+
_MAX31865_FAULT_HIGHTHRESH = const(0x80)
81+
_MAX31865_FAULT_LOWTHRESH = const(0x40)
82+
_MAX31865_FAULT_REFINLOW = const(0x20)
83+
_MAX31865_FAULT_REFINHIGH = const(0x10)
84+
_MAX31865_FAULT_RTDINLOW = const(0x08)
85+
_MAX31865_FAULT_OVUV = const(0x04)
8686
_RTD_A = 3.9083e-3
8787
_RTD_B = -5.775e-7
88-
#pylint: enable=bad-whitespace
88+
# pylint: enable=bad-whitespace
8989

9090

9191
class MAX31865:
@@ -99,11 +99,12 @@ class MAX31865:
9999
def __init__(self, spi, cs, *, rtd_nominal=100, ref_resistor=430.0, wires=2):
100100
self.rtd_nominal = rtd_nominal
101101
self.ref_resistor = ref_resistor
102-
self._device = spi_device.SPIDevice(spi, cs, baudrate=500000,
103-
polarity=0, phase=1)
102+
self._device = spi_device.SPIDevice(
103+
spi, cs, baudrate=500000, polarity=0, phase=1
104+
)
104105
# Set wire config register based on the number of wires specified.
105106
if wires not in (2, 3, 4):
106-
raise ValueError('Wires must be a value of 2, 3, or 4!')
107+
raise ValueError("Wires must be a value of 2, 3, or 4!")
107108
config = self._read_u8(_MAX31865_CONFIG_REG)
108109
if wires == 3:
109110
config |= _MAX31865_CONFIG_3WIRE
@@ -138,6 +139,7 @@ def _write_u8(self, address, val):
138139
self._BUFFER[0] = (address | 0x80) & 0xFF
139140
self._BUFFER[1] = val & 0xFF
140141
device.write(self._BUFFER, end=2)
142+
141143
# pylint: enable=no-member
142144

143145
@property
@@ -165,7 +167,7 @@ def auto_convert(self):
165167
def auto_convert(self, val):
166168
config = self._read_u8(_MAX31865_CONFIG_REG)
167169
if val:
168-
config |= _MAX31865_CONFIG_MODEAUTO # Enable auto convert.
170+
config |= _MAX31865_CONFIG_MODEAUTO # Enable auto convert.
169171
else:
170172
config &= ~_MAX31865_CONFIG_MODEAUTO # Disable auto convert.
171173
self._write_u8(_MAX31865_CONFIG_REG, config)
@@ -184,14 +186,14 @@ def fault(self):
184186
- OVUV
185187
"""
186188
faults = self._read_u8(_MAX31865_FAULTSTAT_REG)
187-
#pylint: disable=bad-whitespace
189+
# pylint: disable=bad-whitespace
188190
highthresh = bool(faults & _MAX31865_FAULT_HIGHTHRESH)
189-
lowthresh = bool(faults & _MAX31865_FAULT_LOWTHRESH)
190-
refinlow = bool(faults & _MAX31865_FAULT_REFINLOW)
191-
refinhigh = bool(faults & _MAX31865_FAULT_REFINHIGH)
192-
rtdinlow = bool(faults & _MAX31865_FAULT_RTDINLOW)
193-
ovuv = bool(faults & _MAX31865_FAULT_OVUV)
194-
#pylint: enable=bad-whitespace
191+
lowthresh = bool(faults & _MAX31865_FAULT_LOWTHRESH)
192+
refinlow = bool(faults & _MAX31865_FAULT_REFINLOW)
193+
refinhigh = bool(faults & _MAX31865_FAULT_REFINHIGH)
194+
rtdinlow = bool(faults & _MAX31865_FAULT_RTDINLOW)
195+
ovuv = bool(faults & _MAX31865_FAULT_OVUV)
196+
# pylint: enable=bad-whitespace
195197
return (highthresh, lowthresh, refinlow, refinhigh, rtdinlow, ovuv)
196198

197199
def clear_faults(self):

docs/conf.py

Lines changed: 68 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
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

@@ -21,29 +22,36 @@
2122
# autodoc module docs will fail to generate with a warning.
2223
# autodoc_mock_imports = ["micropython", "adafruit_bus_device"]
2324

24-
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)}
25+
intersphinx_mapping = {
26+
"python": ("https://docs.python.org/3.4", None),
27+
"BusDevice": (
28+
"https://circuitpython.readthedocs.io/projects/busdevice/en/latest/",
29+
None,
30+
),
31+
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
32+
}
2533

2634
# Add any paths that contain templates here, relative to this directory.
27-
templates_path = ['_templates']
35+
templates_path = ["_templates"]
2836

29-
source_suffix = '.rst'
37+
source_suffix = ".rst"
3038

3139
# The master toctree document.
32-
master_doc = 'index'
40+
master_doc = "index"
3341

3442
# General information about the project.
35-
project = u'Adafruit MAX31865 Library'
36-
copyright = u'2017 Tony DiCola'
37-
author = u'Tony DiCola'
43+
project = u"Adafruit MAX31865 Library"
44+
copyright = u"2017 Tony DiCola"
45+
author = u"Tony DiCola"
3846

3947
# The version info for the project you're documenting, acts as replacement for
4048
# |version| and |release|, also used in various other places throughout the
4149
# built documents.
4250
#
4351
# The short X.Y version.
44-
version = u'1.0'
52+
version = u"1.0"
4553
# The full version, including alpha/beta/rc tags.
46-
release = u'1.0'
54+
release = u"1.0"
4755

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

6068
# The reST default role (used for this markup: `text`) to use for all
6169
# documents.
@@ -67,7 +75,7 @@
6775
add_function_parentheses = True
6876

6977
# The name of the Pygments (syntax highlighting) style to use.
70-
pygments_style = 'sphinx'
78+
pygments_style = "sphinx"
7179

7280
# If true, `todo` and `todoList` produce output, else they produce nothing.
7381
todo_include_todos = False
@@ -81,68 +89,76 @@
8189
# The theme to use for HTML and HTML Help pages. See the documentation for
8290
# a list of builtin themes.
8391
#
84-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
92+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
8593

8694
if not on_rtd: # only import and set the theme if we're building docs locally
8795
try:
8896
import sphinx_rtd_theme
89-
html_theme = 'sphinx_rtd_theme'
90-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
97+
98+
html_theme = "sphinx_rtd_theme"
99+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
91100
except:
92-
html_theme = 'default'
93-
html_theme_path = ['.']
101+
html_theme = "default"
102+
html_theme_path = ["."]
94103
else:
95-
html_theme_path = ['.']
104+
html_theme_path = ["."]
96105

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

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

108117
# Output file base name for HTML help builder.
109-
htmlhelp_basename = 'AdafruitMAX31865Librarydoc'
118+
htmlhelp_basename = "AdafruitMAX31865Librarydoc"
110119

111120
# -- Options for LaTeX output ---------------------------------------------
112121

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

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

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

141152
# One entry per manual page. List of tuples
142153
# (source start file, name, description, authors, manual section).
143154
man_pages = [
144-
(master_doc, 'adafruitMAX31865library', u'Adafruit MAX31865 Library Documentation',
145-
[author], 1)
155+
(
156+
master_doc,
157+
"adafruitMAX31865library",
158+
u"Adafruit MAX31865 Library Documentation",
159+
[author],
160+
1,
161+
)
146162
]
147163

148164
# -- Options for Texinfo output -------------------------------------------
@@ -151,7 +167,13 @@
151167
# (source start file, target name, title, author,
152168
# dir menu entry, description, category)
153169
texinfo_documents = [
154-
(master_doc, 'AdafruitMAX31865Library', u'Adafruit MAX31865 Library Documentation',
155-
author, 'AdafruitMAX31865Library', 'One line description of project.',
156-
'Miscellaneous'),
170+
(
171+
master_doc,
172+
"AdafruitMAX31865Library",
173+
u"Adafruit MAX31865 Library Documentation",
174+
author,
175+
"AdafruitMAX31865Library",
176+
"One line description of project.",
177+
"Miscellaneous",
178+
),
157179
]

examples/max31865_simpletest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
# Note you can optionally provide the thermocouple RTD nominal, the reference
1717
# resistance, and the number of wires for the sensor (2 the default, 3, or 4)
1818
# with keyword args:
19-
#sensor = adafruit_max31865.MAX31865(spi, cs, rtd_nominal=100, ref_resistor=430.0, wires=2)
19+
# sensor = adafruit_max31865.MAX31865(spi, cs, rtd_nominal=100, ref_resistor=430.0, wires=2)
2020

2121
# Main loop to print the temperature every second.
2222
while True:
2323
# Read temperature.
2424
temp = sensor.temperature
2525
# Print the value.
26-
print('Temperature: {0:0.3f}C'.format(temp))
26+
print("Temperature: {0:0.3f}C".format(temp))
2727
# Delay for a second.
2828
time.sleep(1.0)

0 commit comments

Comments
 (0)