Skip to content

Commit 7049c1c

Browse files
authored
Merge pull request #25 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents 2745057 + 63b161b commit 7049c1c

File tree

10 files changed

+156
-136
lines changed

10 files changed

+156
-136
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_mcp230xx/digital_inout.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@
3838
def _get_bit(val, bit):
3939
return val & (1 << bit) > 0
4040

41+
4142
def _enable_bit(val, bit):
4243
return val | (1 << bit)
4344

45+
4446
def _clear_bit(val, bit):
4547
return val & ~(1 << bit)
4648

@@ -63,7 +65,7 @@ def __init__(self, pin_number, mcp230xx):
6365
# with DigitalInout class (which allows specifying pull, etc. which
6466
# is unused by this class). Do not remove them, instead turn off pylint
6567
# in this case.
66-
#pylint: disable=unused-argument
68+
# pylint: disable=unused-argument
6769
def switch_to_output(self, value=False, **kwargs):
6870
"""Switch the pin state to a digital output with the provided starting
6971
value (True/False for high or low, default is False/low).
@@ -78,7 +80,8 @@ def switch_to_input(self, pull=None, **kwargs):
7880
"""
7981
self.direction = digitalio.Direction.INPUT
8082
self.pull = pull
81-
#pylint: enable=unused-argument
83+
84+
# pylint: enable=unused-argument
8285

8386
@property
8487
def value(self):
@@ -111,7 +114,7 @@ def direction(self, val):
111114
elif val == digitalio.Direction.OUTPUT:
112115
self._mcp.iodir = _clear_bit(self._mcp.iodir, self._pin)
113116
else:
114-
raise ValueError('Expected INPUT or OUTPUT direction!')
117+
raise ValueError("Expected INPUT or OUTPUT direction!")
115118

116119
@property
117120
def pull(self):
@@ -130,6 +133,6 @@ def pull(self, val):
130133
elif val == digitalio.Pull.UP:
131134
self._mcp.gppu = _enable_bit(self._mcp.gppu, self._pin)
132135
elif val == digitalio.Pull.DOWN:
133-
raise ValueError('Pull-down resistors are not supported!')
136+
raise ValueError("Pull-down resistors are not supported!")
134137
else:
135-
raise ValueError('Expected UP, DOWN, or None for pull state!')
138+
raise ValueError("Expected UP, DOWN, or None for pull state!")

adafruit_mcp230xx/mcp23008.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@
3737
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MCP230xx.git"
3838

3939
# pylint: disable=bad-whitespace
40-
_MCP23008_ADDRESS = const(0x20)
41-
_MCP23008_IODIR = const(0x00)
42-
_MCP23008_IPOL = const(0x01)
43-
_MCP23008_GPINTEN = const(0x02)
44-
_MCP23008_DEFVAL = const(0x03)
45-
_MCP23008_INTCON = const(0x04)
46-
_MCP23008_IOCON = const(0x05)
47-
_MCP23008_GPPU = const(0x06)
48-
_MCP23008_INTF = const(0x07)
49-
_MCP23008_INTCAP = const(0x08)
50-
_MCP23008_GPIO = const(0x09)
40+
_MCP23008_ADDRESS = const(0x20)
41+
_MCP23008_IODIR = const(0x00)
42+
_MCP23008_IPOL = const(0x01)
43+
_MCP23008_GPINTEN = const(0x02)
44+
_MCP23008_DEFVAL = const(0x03)
45+
_MCP23008_INTCON = const(0x04)
46+
_MCP23008_IOCON = const(0x05)
47+
_MCP23008_GPPU = const(0x06)
48+
_MCP23008_INTF = const(0x07)
49+
_MCP23008_INTCAP = const(0x08)
50+
_MCP23008_GPIO = const(0x09)
5151

5252

5353
class MCP23008(MCP230XX):
@@ -60,7 +60,7 @@ def __init__(self, i2c, address=_MCP23008_ADDRESS):
6060

6161
# Reset to all inputs with no pull-ups and no inverted polarity.
6262
self.iodir = 0xFF
63-
self.gppu = 0x00
63+
self.gppu = 0x00
6464
self._write_u8(_MCP23008_IPOL, 0x00)
6565

6666
@property

adafruit_mcp230xx/mcp23017.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,22 @@
3737
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MCP230xx.git"
3838

3939
# pylint: disable=bad-whitespace
40-
_MCP23017_ADDRESS = const(0x20)
41-
_MCP23017_IODIRA = const(0x00)
42-
_MCP23017_IODIRB = const(0x01)
43-
_MCP23017_IPOLA = const(0x02)
44-
_MCP23017_GPINTENA = const(0x04)
45-
_MCP23017_DEFVALA = const(0x06)
46-
_MCP23017_INTCONA = const(0x08)
47-
_MCP23017_IOCON = const(0x0A)
48-
_MCP23017_GPPUA = const(0x0C)
49-
_MCP23017_GPPUB = const(0x0D)
50-
_MCP23017_GPIOA = const(0x12)
51-
_MCP23017_GPIOB = const(0x13)
52-
_MCP23017_INTFA = const(0x0E)
53-
_MCP23017_INTFB = const(0x0F)
54-
_MCP23017_INTCAPA = const(0x10)
55-
_MCP23017_INTCAPB = const(0x11)
40+
_MCP23017_ADDRESS = const(0x20)
41+
_MCP23017_IODIRA = const(0x00)
42+
_MCP23017_IODIRB = const(0x01)
43+
_MCP23017_IPOLA = const(0x02)
44+
_MCP23017_GPINTENA = const(0x04)
45+
_MCP23017_DEFVALA = const(0x06)
46+
_MCP23017_INTCONA = const(0x08)
47+
_MCP23017_IOCON = const(0x0A)
48+
_MCP23017_GPPUA = const(0x0C)
49+
_MCP23017_GPPUB = const(0x0D)
50+
_MCP23017_GPIOA = const(0x12)
51+
_MCP23017_GPIOB = const(0x13)
52+
_MCP23017_INTFA = const(0x0E)
53+
_MCP23017_INTFB = const(0x0F)
54+
_MCP23017_INTCAPA = const(0x10)
55+
_MCP23017_INTCAPB = const(0x11)
5656

5757

5858
class MCP23017(MCP230XX):
@@ -65,7 +65,7 @@ def __init__(self, i2c, address=_MCP23017_ADDRESS):
6565
# Reset to all inputs with no pull-ups and no inverted polarity.
6666
self.iodir = 0xFFFF
6767
self.gppu = 0x0000
68-
self.iocon = 0x4 # turn on IRQ Pins as open drain
68+
self.iocon = 0x4 # turn on IRQ Pins as open drain
6969
self._write_u16le(_MCP23017_IPOLA, 0x0000)
7070

7171
@property
@@ -263,7 +263,7 @@ def int_flagb(self):
263263
pins: 8-15
264264
"""
265265
intfb = self._read_u8(_MCP23017_INTFB)
266-
flags = [pin+8 for pin in range(8) if intfb & (1 << pin)]
266+
flags = [pin + 8 for pin in range(8) if intfb & (1 << pin)]
267267
return flags
268268

269269
def clear_ints(self):

docs/conf.py

Lines changed: 68 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
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',
14+
"sphinx.ext.autodoc",
15+
"sphinx.ext.intersphinx",
1516
#'sphinx.ext.napoleon'
16-
'sphinx.ext.todo',
17+
"sphinx.ext.todo",
1718
]
1819

1920
# TODO: Please Read!
@@ -23,29 +24,36 @@
2324
autodoc_mock_imports = ["micropython", "adafruit_bus_device", "digitalio"]
2425

2526

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

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

31-
source_suffix = '.rst'
39+
source_suffix = ".rst"
3240

3341
# The master toctree document.
34-
master_doc = 'index'
42+
master_doc = "index"
3543

3644
# General information about the project.
37-
project = u'Adafruit MCP230xx Library'
38-
copyright = u'2017 Tony DiCola'
39-
author = u'Tony DiCola'
45+
project = u"Adafruit MCP230xx Library"
46+
copyright = u"2017 Tony DiCola"
47+
author = u"Tony DiCola"
4048

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

5058
# The language for content autogenerated by Sphinx. Refer to documentation
5159
# for a list of supported languages.
@@ -57,7 +65,7 @@
5765
# List of patterns, relative to source directory, that match files and
5866
# directories to ignore when looking for source files.
5967
# This patterns also effect to html_static_path and html_extra_path
60-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
68+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
6169

6270
# The reST default role (used for this markup: `text`) to use for all
6371
# documents.
@@ -69,7 +77,7 @@
6977
add_function_parentheses = True
7078

7179
# The name of the Pygments (syntax highlighting) style to use.
72-
pygments_style = 'sphinx'
80+
pygments_style = "sphinx"
7381

7482
# If true, `todo` and `todoList` produce output, else they produce nothing.
7583
todo_include_todos = False
@@ -84,68 +92,76 @@
8492
# The theme to use for HTML and HTML Help pages. See the documentation for
8593
# a list of builtin themes.
8694
#
87-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
95+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
8896

8997
if not on_rtd: # only import and set the theme if we're building docs locally
9098
try:
9199
import sphinx_rtd_theme
92-
html_theme = 'sphinx_rtd_theme'
93-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
100+
101+
html_theme = "sphinx_rtd_theme"
102+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
94103
except:
95-
html_theme = 'default'
96-
html_theme_path = ['.']
104+
html_theme = "default"
105+
html_theme_path = ["."]
97106
else:
98-
html_theme_path = ['.']
107+
html_theme_path = ["."]
99108

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

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

111120
# Output file base name for HTML help builder.
112-
htmlhelp_basename = 'AdafruitMcp230xxLibrarydoc'
121+
htmlhelp_basename = "AdafruitMcp230xxLibrarydoc"
113122

114123
# -- Options for LaTeX output ---------------------------------------------
115124

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

134140
# Grouping the document tree into LaTeX files. List of tuples
135141
# (source start file, target name, title,
136142
# author, documentclass [howto, manual, or own class]).
137143
latex_documents = [
138-
(master_doc, 'AdafruitMCP230xxLibrary.tex', u'AdafruitMCP230xx Library Documentation',
139-
author, 'manual'),
144+
(
145+
master_doc,
146+
"AdafruitMCP230xxLibrary.tex",
147+
u"AdafruitMCP230xx Library Documentation",
148+
author,
149+
"manual",
150+
),
140151
]
141152

142153
# -- Options for manual page output ---------------------------------------
143154

144155
# One entry per manual page. List of tuples
145156
# (source start file, name, description, authors, manual section).
146157
man_pages = [
147-
(master_doc, 'AdafruitMCP230xxlibrary', u'Adafruit MCP230xx Library Documentation',
148-
[author], 1)
158+
(
159+
master_doc,
160+
"AdafruitMCP230xxlibrary",
161+
u"Adafruit MCP230xx Library Documentation",
162+
[author],
163+
1,
164+
)
149165
]
150166

151167
# -- Options for Texinfo output -------------------------------------------
@@ -154,7 +170,13 @@
154170
# (source start file, target name, title, author,
155171
# dir menu entry, description, category)
156172
texinfo_documents = [
157-
(master_doc, 'AdafruitMCP230xxLibrary', u'Adafruit MCP230xx Library Documentation',
158-
author, 'AdafruitMCP230xxLibrary', 'One line description of project.',
159-
'Miscellaneous'),
173+
(
174+
master_doc,
175+
"AdafruitMCP230xxLibrary",
176+
u"Adafruit MCP230xx Library Documentation",
177+
author,
178+
"AdafruitMCP230xxLibrary",
179+
"One line description of project.",
180+
"Miscellaneous",
181+
),
160182
]

0 commit comments

Comments
 (0)