Skip to content

Commit 3abe3b7

Browse files
authored
Merge pull request #48 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents 5297ceb + a489e58 commit 3abe3b7

File tree

9 files changed

+211
-165
lines changed

9 files changed

+211
-165
lines changed

.github/workflows/build.yml

+1-1
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

+2-1
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_bus_device/i2c_device.py

+25-9
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
__version__ = "0.0.0-auto.0"
2929
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BusDevice.git"
3030

31+
3132
class I2CDevice:
3233
"""
3334
Represents a single I2C device and manages locking the bus and the device
@@ -61,7 +62,7 @@ class I2CDevice:
6162
def __init__(self, i2c, device_address, probe=True):
6263

6364
self.i2c = i2c
64-
self._has_write_read = hasattr(self.i2c, 'writeto_then_readfrom')
65+
self._has_write_read = hasattr(self.i2c, "writeto_then_readfrom")
6566
self.device_address = device_address
6667

6768
if probe:
@@ -102,9 +103,18 @@ def write(self, buf, *, start=0, end=None, stop=True):
102103
end = len(buf)
103104
self.i2c.writeto(self.device_address, buf, start=start, end=end, stop=stop)
104105

105-
#pylint: disable-msg=too-many-arguments
106-
def write_then_readinto(self, out_buffer, in_buffer, *,
107-
out_start=0, out_end=None, in_start=0, in_end=None, stop=False):
106+
# pylint: disable-msg=too-many-arguments
107+
def write_then_readinto(
108+
self,
109+
out_buffer,
110+
in_buffer,
111+
*,
112+
out_start=0,
113+
out_end=None,
114+
in_start=0,
115+
in_end=None,
116+
stop=False
117+
):
108118
"""
109119
Write the bytes from ``out_buffer`` to the device, then immediately
110120
reads into ``in_buffer`` from the device. The number of bytes read
@@ -136,16 +146,22 @@ def write_then_readinto(self, out_buffer, in_buffer, *,
136146
raise ValueError("Stop must be False. Use writeto instead.")
137147
if self._has_write_read:
138148
# In linux, at least, this is a special kernel function call
139-
self.i2c.writeto_then_readfrom(self.device_address, out_buffer, in_buffer,
140-
out_start=out_start, out_end=out_end,
141-
in_start=in_start, in_end=in_end)
149+
self.i2c.writeto_then_readfrom(
150+
self.device_address,
151+
out_buffer,
152+
in_buffer,
153+
out_start=out_start,
154+
out_end=out_end,
155+
in_start=in_start,
156+
in_end=in_end,
157+
)
142158

143159
else:
144160
# If we don't have a special implementation, we can fake it with two calls
145161
self.write(out_buffer, start=out_start, end=out_end, stop=False)
146162
self.readinto(in_buffer, start=in_start, end=in_end)
147163

148-
#pylint: enable-msg=too-many-arguments
164+
# pylint: enable-msg=too-many-arguments
149165

150166
def __enter__(self):
151167
while not self.i2c.try_lock():
@@ -165,7 +181,7 @@ def __probe_for_device(self):
165181
while not self.i2c.try_lock():
166182
pass
167183
try:
168-
self.i2c.writeto(self.device_address, b'')
184+
self.i2c.writeto(self.device_address, b"")
169185
except OSError:
170186
# some OS's dont like writing an empty bytesting...
171187
# Retry by reading a byte

adafruit_bus_device/spi_device.py

+16-5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
__version__ = "0.0.0-auto.0"
3030
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BusDevice.git"
3131

32+
3233
class SPIDevice:
3334
"""
3435
Represents a single SPI device and manages locking the bus and the device
@@ -65,8 +66,17 @@ class SPIDevice:
6566
with device as spi:
6667
spi.write(bytes_read)
6768
"""
68-
def __init__(self, spi, chip_select=None, *,
69-
baudrate=100000, polarity=0, phase=0, extra_clocks=0):
69+
70+
def __init__(
71+
self,
72+
spi,
73+
chip_select=None,
74+
*,
75+
baudrate=100000,
76+
polarity=0,
77+
phase=0,
78+
extra_clocks=0
79+
):
7080
self.spi = spi
7181
self.baudrate = baudrate
7282
self.polarity = polarity
@@ -79,8 +89,9 @@ def __init__(self, spi, chip_select=None, *,
7989
def __enter__(self):
8090
while not self.spi.try_lock():
8191
pass
82-
self.spi.configure(baudrate=self.baudrate, polarity=self.polarity,
83-
phase=self.phase)
92+
self.spi.configure(
93+
baudrate=self.baudrate, polarity=self.polarity, phase=self.phase
94+
)
8495
if self.chip_select:
8596
self.chip_select.value = False
8697
return self.spi
@@ -90,7 +101,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
90101
self.chip_select.value = True
91102
if self.extra_clocks > 0:
92103
buf = bytearray(1)
93-
buf[0] = 0xff
104+
buf[0] = 0xFF
94105
clocks = self.extra_clocks // 8
95106
if self.extra_clocks % 8 != 0:
96107
clocks += 1

docs/conf.py

+70-48
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", "micropython"]
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", "micropython"]
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 CircuitPython Bus Device'
35-
copyright = u'2016-2017 Scott Shawcroft and Tony Dicola for Adafruit Industries'
36-
author = u'Scott Shawcroft and Tony Dicola'
42+
project = u"Adafruit CircuitPython Bus Device"
43+
copyright = u"2016-2017 Scott Shawcroft and Tony Dicola for Adafruit Industries"
44+
author = u"Scott Shawcroft and Tony Dicola"
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 = 'AdafruitBusDeviceLibrarydoc'
117+
htmlhelp_basename = "AdafruitBusDeviceLibrarydoc"
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, 'AdafruitBusDeviceLibrary.tex', u'Adafruit Bus Device Library Documentation',
135-
author, 'manual'),
140+
(
141+
master_doc,
142+
"AdafruitBusDeviceLibrary.tex",
143+
u"Adafruit Bus Device 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, 'AdafruitBusDeviceLibrary', u'Adafruit Bus Device Library Documentation',
144-
[author], 1)
154+
(
155+
master_doc,
156+
"AdafruitBusDeviceLibrary",
157+
u"Adafruit Bus Device 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, 'AdafruitBusDeviceLibrary', u'Adafruit Bus Device Library Documentation',
154-
author, 'AdafruitBusDeviceLibrary', 'One line description of project.',
155-
'Miscellaneous'),
169+
(
170+
master_doc,
171+
"AdafruitBusDeviceLibrary",
172+
u"Adafruit Bus Device Library Documentation",
173+
author,
174+
"AdafruitBusDeviceLibrary",
175+
"One line description of project.",
176+
"Miscellaneous",
177+
),
156178
]

0 commit comments

Comments
 (0)