Skip to content

Commit 42443c8

Browse files
authored
Merge pull request #19 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents 063ba6f + 80a2d65 commit 42443c8

File tree

7 files changed

+113
-94
lines changed

7 files changed

+113
-94
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_onewire/bus.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@
3939
_SKIP_ROM = const(0xCC)
4040
_MAX_DEV = const(10)
4141

42+
4243
class OneWireError(Exception):
4344
"""A class to represent a 1-Wire exception."""
44-
pass
4545

46-
class OneWireAddress(object):
46+
47+
class OneWireAddress:
4748
"""A class to represent a 1-Wire address."""
4849

4950
def __init__(self, rom):
@@ -69,7 +70,8 @@ def family_code(self):
6970
"""The 8 bit family code."""
7071
return self._rom[0]
7172

72-
class OneWireBus(object):
73+
74+
class OneWireBus:
7375
"""A class to represent a 1-Wire bus."""
7476

7577
def __init__(self, pin):
@@ -90,7 +92,7 @@ def maximum_devices(self):
9092
def maximum_devices(self, count):
9193
if not isinstance(count, int):
9294
raise ValueError("Maximum must be an integer value 1 - 255.")
93-
if count < 1 or count > 0xff:
95+
if count < 1 or count > 0xFF:
9496
raise ValueError("Maximum must be an integer value 1 - 255.")
9597
self._maximum_devices = count
9698

@@ -146,14 +148,16 @@ def scan(self):
146148
diff = 65
147149
rom = False
148150
count = 0
149-
for _ in range(0xff):
151+
for _ in range(0xFF):
150152
rom, diff = self._search_rom(rom, diff)
151153
if rom:
152154
count += 1
153155
if count > self.maximum_devices:
154156
raise RuntimeError(
155-
"Maximum device count of {} exceeded."\
156-
.format(self.maximum_devices))
157+
"Maximum device count of {} exceeded.".format(
158+
self.maximum_devices
159+
)
160+
)
157161
devices.append(OneWireAddress(rom))
158162
if diff == 0:
159163
break
@@ -169,7 +173,6 @@ def _writebyte(self, value):
169173
for i in range(8):
170174
bit = (value >> i) & 0x1
171175
self._ow.write_bit(bit)
172-
return
173176

174177
def _search_rom(self, l_rom, diff):
175178
if not self.reset():
@@ -185,10 +188,10 @@ def _search_rom(self, l_rom, diff):
185188
for bit in range(8):
186189
b = self._readbit()
187190
if self._readbit():
188-
if b: # there are no devices or there is an error on the bus
191+
if b: # there are no devices or there is an error on the bus
189192
return None, 0
190193
else:
191-
if not b: # collision, two devices with different bit meaning
194+
if not b: # collision, two devices with different bit meaning
192195
if diff > i or ((l_rom[byte] & (1 << bit)) and diff != i):
193196
b = 1
194197
next_diff = i

adafruit_onewire/device.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@
3131
__version__ = "0.0.0-auto.0"
3232
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_OneWire.git"
3333

34-
_MATCH_ROM = b'\x55'
34+
_MATCH_ROM = b"\x55"
3535

36-
class OneWireDevice(object):
36+
37+
class OneWireDevice:
3738
"""A class to represent a single device on the 1-Wire bus."""
3839

3940
def __init__(self, bus, address):
@@ -63,7 +64,7 @@ def readinto(self, buf, *, start=0, end=None):
6364
self._bus.readinto(buf, start=start, end=end)
6465
if start == 0 and end is None and len(buf) >= 8:
6566
if self._bus.crc8(buf):
66-
raise RuntimeError('CRC error.')
67+
raise RuntimeError("CRC error.")
6768

6869
def write(self, buf, *, start=0, end=None):
6970
"""

docs/conf.py

Lines changed: 68 additions & 46 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.
2122
# autodoc_mock_imports = ["busio", "micropython"]
2223

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)}
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 OneWire Library'
35-
copyright = u'2017 Carter Nelson'
36-
author = u'Carter Nelson'
42+
project = u"Adafruit OneWire Library"
43+
copyright = u"2017 Carter Nelson"
44+
author = u"Carter Nelson"
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
@@ -80,68 +88,76 @@
8088
# The theme to use for HTML and HTML Help pages. See the documentation for
8189
# a list of builtin themes.
8290
#
83-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
91+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
8492

8593
if not on_rtd: # only import and set the theme if we're building docs locally
8694
try:
8795
import sphinx_rtd_theme
88-
html_theme = 'sphinx_rtd_theme'
89-
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(), "."]
9099
except:
91-
html_theme = 'default'
92-
html_theme_path = ['.']
100+
html_theme = "default"
101+
html_theme_path = ["."]
93102
else:
94-
html_theme_path = ['.']
103+
html_theme_path = ["."]
95104

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

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

107116
# Output file base name for HTML help builder.
108-
htmlhelp_basename = 'AdafruitOnewireLibrarydoc'
117+
htmlhelp_basename = "AdafruitOnewireLibrarydoc"
109118

110119
# -- Options for LaTeX output ---------------------------------------------
111120

112121
latex_elements = {
113-
# The paper size ('letterpaper' or 'a4paper').
114-
#
115-
# 'papersize': 'letterpaper',
116-
117-
# The font size ('10pt', '11pt' or '12pt').
118-
#
119-
# 'pointsize': '10pt',
120-
121-
# Additional stuff for the LaTeX preamble.
122-
#
123-
# 'preamble': '',
124-
125-
# Latex figure (float) alignment
126-
#
127-
# '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',
128134
}
129135

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

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

140151
# One entry per manual page. List of tuples
141152
# (source start file, name, description, authors, manual section).
142153
man_pages = [
143-
(master_doc, 'AdafruitOneWirelibrary', u'Adafruit OneWire Library Documentation',
144-
[author], 1)
154+
(
155+
master_doc,
156+
"AdafruitOneWirelibrary",
157+
u"Adafruit OneWire Library Documentation",
158+
[author],
159+
1,
160+
)
145161
]
146162

147163
# -- Options for Texinfo output -------------------------------------------
@@ -150,7 +166,13 @@
150166
# (source start file, target name, title, author,
151167
# dir menu entry, description, category)
152168
texinfo_documents = [
153-
(master_doc, 'AdafruitOneWireLibrary', u'Adafruit OneWire Library Documentation',
154-
author, 'AdafruitOneWireLibrary', 'One line description of project.',
155-
'Miscellaneous'),
169+
(
170+
master_doc,
171+
"AdafruitOneWireLibrary",
172+
u"Adafruit OneWire Library Documentation",
173+
author,
174+
"AdafruitOneWireLibrary",
175+
"One line description of project.",
176+
"Miscellaneous",
177+
),
156178
]

examples/onewire_simpletest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@
77

88
# Reset and check for presence pulse.
99
# This is basically - "is there anything out there?"
10-
print("Resetting bus...", end='')
10+
print("Resetting bus...", end="")
1111
if ow_bus.reset():
1212
print("OK.")
1313
else:
1414
raise RuntimeError("Nothing found on bus.")
1515

1616
# Run a scan to get all of the device ROM values
17-
print("Scanning for devices...", end='')
17+
print("Scanning for devices...", end="")
1818
devices = ow_bus.scan()
1919
print("OK.")
2020
print("Found {} device(s).".format(len(devices)))
2121

2222
# For each device found, print out some info
2323
for i, d in enumerate(devices):
2424
print("Device {:>3}".format(i))
25-
print("\tSerial Number = ", end='')
25+
print("\tSerial Number = ", end="")
2626
for byte in d.serial_number:
27-
print("0x{:02x} ".format(byte), end='')
27+
print("0x{:02x} ".format(byte), end="")
2828
print("\n\tFamily = 0x{:02x}".format(d.family_code))
2929

3030
# Usage beyond this is device specific. See a CircuitPython library for a 1-Wire

0 commit comments

Comments
 (0)