Skip to content

Commit edde9a7

Browse files
authored
Merge pull request #25 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents bfb988b + b015717 commit edde9a7

File tree

8 files changed

+140
-118
lines changed

8 files changed

+140
-118
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_max7219/bcddigits.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
_SHUTDOWN = const(12)
3737
_DISPLAYTEST = const(15)
3838

39+
3940
class BCDDigits(max7219.MAX7219):
4041
"""
4142
Basic support for display on a 7-Segment BCD display controlled
@@ -45,18 +46,20 @@ class BCDDigits(max7219.MAX7219):
4546
:param ~digitalio.DigitalInOut cs: digital in/out to use as chip select signal
4647
:param int nDigits: number of led 7-segment digits; default 1; max 8
4748
"""
49+
4850
def __init__(self, spi, cs, nDigits=1):
4951
self._ndigits = nDigits
5052
super().__init__(self._ndigits, 8, spi, cs)
5153

5254
def init_display(self):
5355

54-
for cmd, data in ((_SHUTDOWN, 0),
55-
(_DISPLAYTEST, 0),
56-
(_SCANLIMIT, 7),
57-
(_DECODEMODE, (2**self._ndigits)-1),
58-
(_SHUTDOWN, 1),
59-
):
56+
for cmd, data in (
57+
(_SHUTDOWN, 0),
58+
(_DISPLAYTEST, 0),
59+
(_SCANLIMIT, 7),
60+
(_DECODEMODE, (2 ** self._ndigits) - 1),
61+
(_SHUTDOWN, 1),
62+
):
6063
self.write_cmd(cmd, data)
6164

6265
self.clear_all()
@@ -71,7 +74,7 @@ def set_digit(self, dpos, value):
7174
"""
7275
dpos = self._ndigits - dpos - 1
7376
for i in range(4):
74-
#print('digit {} pixel {} value {}'.format(dpos,i+4,v & 0x01))
77+
# print('digit {} pixel {} value {}'.format(dpos,i+4,v & 0x01))
7578
self.pixel(dpos, i, value & 0x01)
7679
value >>= 1
7780

@@ -83,7 +86,7 @@ def set_digits(self, start, values):
8386
:param list ds: list of integer values ranging from 0->15
8487
"""
8588
for value in values:
86-
#print('set digit {} start {}'.format(d,start))
89+
# print('set digit {} start {}'.format(d,start))
8790
self.set_digit(start, value)
8891
start += 1
8992

@@ -94,9 +97,9 @@ def show_dot(self, dpos, bit_value=None):
9497
:param int dpos: the digit to set the decimal point zero-based
9598
:param int value: value > zero lights the decimal point, else unlights the point
9699
"""
97-
if dpos < self._ndigits and dpos >= 0:
98-
#print('set dot {} = {}'.format((self._ndigits - d -1),col))
99-
self.pixel(self._ndigits-dpos-1, 7, bit_value)
100+
if 0 <= dpos < self._ndigits:
101+
# print('set dot {} = {}'.format((self._ndigits - d -1),col))
102+
self.pixel(self._ndigits - dpos - 1, 7, bit_value)
100103

101104
def clear_all(self):
102105
"""
@@ -116,13 +119,13 @@ def show_str(self, start, strg):
116119
cpos = start
117120
for char in strg:
118121
# print('c {}'.format(c))
119-
value = 0x0f # assume blank
120-
if char >= '0' and char <= '9':
122+
value = 0x0F # assume blank
123+
if "0" <= char <= "9":
121124
value = int(char)
122-
elif char == '-':
123-
value = 10 # minus sign
124-
elif char == '.':
125-
self.show_dot(cpos-1, 1)
125+
elif char == "-":
126+
value = 10 # minus sign
127+
elif char == ".":
128+
self.show_dot(cpos - 1, 1)
126129
continue
127130
self.set_digit(cpos, value)
128131
cpos += 1

adafruit_max7219/matrices.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,26 @@
3636
_SHUTDOWN = const(12)
3737
_DISPLAYTEST = const(15)
3838

39+
3940
class Matrix8x8(max7219.MAX7219):
4041
"""
4142
Driver for a 8x8 LED matrix based on the MAX7219 chip.
4243
4344
:param object spi: an spi busio or spi bitbangio object
4445
:param ~digitalio.DigitalInOut cs: digital in/out to use as chip select signal
4546
"""
47+
4648
def __init__(self, spi, cs):
4749
super().__init__(8, 8, spi, cs)
4850

4951
def init_display(self):
50-
for cmd, data in ((_SHUTDOWN, 0),
51-
(_DISPLAYTEST, 0),
52-
(_SCANLIMIT, 7),
53-
(_DECODEMODE, 0),
54-
(_SHUTDOWN, 1),
55-
):
52+
for cmd, data in (
53+
(_SHUTDOWN, 0),
54+
(_DISPLAYTEST, 0),
55+
(_SCANLIMIT, 7),
56+
(_DECODEMODE, 0),
57+
(_SHUTDOWN, 1),
58+
):
5659
self.write_cmd(cmd, data)
5760

5861
self.fill(0)

adafruit_max7219/max7219.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,17 @@ class MAX7219:
7979
:param polarity: for SPIDevice polarity (default 0)
8080
:param phase: for SPIDevice phase (default 0)
8181
"""
82-
def __init__(self, width, height, spi, cs, *,
83-
baudrate=8000000, polarity=0, phase=0):
82+
83+
def __init__(
84+
self, width, height, spi, cs, *, baudrate=8000000, polarity=0, phase=0
85+
):
8486

8587
self._chip_select = cs
8688
self._chip_select.direction = digitalio.Direction.OUTPUT
8789

88-
self._spi_device = spi_device.SPIDevice(spi, cs, baudrate=baudrate,
89-
polarity=polarity, phase=phase)
90+
self._spi_device = spi_device.SPIDevice(
91+
spi, cs, baudrate=baudrate, polarity=polarity, phase=phase
92+
)
9093

9194
self._buffer = bytearray((height // 8) * width)
9295
self.framebuf = framebuf.FrameBuffer1(self._buffer, width, height)
@@ -98,7 +101,6 @@ def __init__(self, width, height, spi, cs, *,
98101

99102
def init_display(self):
100103
"""Must be implemented by derived class (``matrices``, ``bcddigits``)"""
101-
pass
102104

103105
def brightness(self, value):
104106
"""
@@ -143,7 +145,7 @@ def scroll(self, delta_x, delta_y):
143145
def write_cmd(self, cmd, data):
144146
# pylint: disable=no-member
145147
"""Writes a command to spi device."""
146-
#print('cmd {} data {}'.format(cmd,data))
148+
# print('cmd {} data {}'.format(cmd,data))
147149
self._chip_select.value = False
148150
with self._spi_device as my_spi_device:
149151
my_spi_device.write(bytearray([cmd, data]))

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 = ["framebuf"]
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 MAX7219 Library'
35-
copyright = u'2017, Adafruit CiruitPython and Bundle contributors'
36-
author = u'Michael McWethy'
42+
project = u"Adafruit MAX7219 Library"
43+
copyright = u"2017, Adafruit CiruitPython and Bundle contributors"
44+
author = u"Michael McWethy"
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 = 'AdafruitMAX7219Librarydoc'
117+
htmlhelp_basename = "AdafruitMAX7219Librarydoc"
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, 'AdafruitMAX7219Library.tex', u'Adafruit MAX7219 Library Documentation',
135-
author, 'manual'),
140+
(
141+
master_doc,
142+
"AdafruitMAX7219Library.tex",
143+
u"Adafruit MAX7219 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, 'adafruitMAX7219library', u'Adafruit MAX7219 Library Documentation',
144-
[author], 1)
154+
(
155+
master_doc,
156+
"adafruitMAX7219library",
157+
u"Adafruit MAX7219 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, 'AdafruitMAX7219Library', u'Adafruit MAX7219 Library Documentation',
154-
author, 'AdafruitMAX7219Library', 'Python driver classes for MAX7219 chip',
155-
'Miscellaneous'),
169+
(
170+
master_doc,
171+
"AdafruitMAX7219Library",
172+
u"Adafruit MAX7219 Library Documentation",
173+
author,
174+
"AdafruitMAX7219Library",
175+
"Python driver classes for MAX7219 chip",
176+
"Miscellaneous",
177+
),
156178
]

0 commit comments

Comments
 (0)