Skip to content

Commit e0d2dc5

Browse files
authored
Merge pull request #14 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents bc7fcfd + 5a99c06 commit e0d2dc5

File tree

7 files changed

+152
-120
lines changed

7 files changed

+152
-120
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

adafruit_cap1188/cap1188.py

+43-34
Original file line numberDiff line numberDiff line change
@@ -48,38 +48,42 @@
4848
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_CAP1188.git"
4949

5050
# pylint: disable=bad-whitespace
51-
_CAP1188_MID = const(0x5D)
52-
_CAP1188_PID = const(0x50)
53-
_CAP1188_MAIN_CONTROL = const(0x00)
54-
_CAP1188_GENERAL_STATUS = const(0x02)
55-
_CAP1188_INPUT_STATUS = const(0x03)
56-
_CAP1188_LED_STATUS = const(0x04)
57-
_CAP1188_NOISE_FLAGS = const(0x0A)
58-
_CAP1188_DELTA_COUNT =(const(0x10),
59-
const(0x11),
60-
const(0x12),
61-
const(0x13),
62-
const(0x14),
63-
const(0x15),
64-
const(0x16),
65-
const(0x17))
66-
_CAP1188_SENSITIVTY = const(0x1F)
67-
_CAP1188_CAL_ACTIVATE = const(0x26)
68-
_CAP1188_MULTI_TOUCH_CFG = const(0x2A)
69-
_CAP1188_THESHOLD_1 = const(0x30)
70-
_CAP1188_STANDBY_CFG = const(0x41)
71-
_CAP1188_LED_LINKING = const(0x72)
72-
_CAP1188_PRODUCT_ID = const(0xFD)
73-
_CAP1188_MANU_ID = const(0xFE)
74-
_CAP1188_REVISION = const(0xFF)
51+
_CAP1188_MID = const(0x5D)
52+
_CAP1188_PID = const(0x50)
53+
_CAP1188_MAIN_CONTROL = const(0x00)
54+
_CAP1188_GENERAL_STATUS = const(0x02)
55+
_CAP1188_INPUT_STATUS = const(0x03)
56+
_CAP1188_LED_STATUS = const(0x04)
57+
_CAP1188_NOISE_FLAGS = const(0x0A)
58+
_CAP1188_DELTA_COUNT = (
59+
const(0x10),
60+
const(0x11),
61+
const(0x12),
62+
const(0x13),
63+
const(0x14),
64+
const(0x15),
65+
const(0x16),
66+
const(0x17),
67+
)
68+
_CAP1188_SENSITIVTY = const(0x1F)
69+
_CAP1188_CAL_ACTIVATE = const(0x26)
70+
_CAP1188_MULTI_TOUCH_CFG = const(0x2A)
71+
_CAP1188_THESHOLD_1 = const(0x30)
72+
_CAP1188_STANDBY_CFG = const(0x41)
73+
_CAP1188_LED_LINKING = const(0x72)
74+
_CAP1188_PRODUCT_ID = const(0xFD)
75+
_CAP1188_MANU_ID = const(0xFE)
76+
_CAP1188_REVISION = const(0xFF)
7577
# pylint: enable=bad-whitespace
7678

7779
_SENSITIVITY = (128, 64, 32, 16, 8, 4, 2, 1)
7880

81+
7982
class CAP1188_Channel:
8083
# pylint: disable=protected-access
8184
"""Helper class to represent a touch channel on the CAP1188. Not meant to
8285
be used directly."""
86+
8387
def __init__(self, cap1188, pin):
8488
self._cap1188 = cap1188
8589
self._pin = pin
@@ -113,24 +117,29 @@ def recalibrate(self):
113117

114118
class CAP1188:
115119
"""CAP1188 driver base, must be extended for I2C/SPI interfacing."""
120+
116121
def __init__(self):
117122
mid = self._read_register(_CAP1188_MANU_ID)
118123
if mid != _CAP1188_MID:
119-
raise RuntimeError('Failed to find CAP1188! Manufacturer ID: 0x{:02x}'.format(mid))
124+
raise RuntimeError(
125+
"Failed to find CAP1188! Manufacturer ID: 0x{:02x}".format(mid)
126+
)
120127
pid = self._read_register(_CAP1188_PRODUCT_ID)
121128
if pid != _CAP1188_PID:
122-
raise RuntimeError('Failed to find CAP1188! Product ID: 0x{:02x}'.format(pid))
123-
self._channels = [None]*8
124-
self._write_register(_CAP1188_LED_LINKING, 0xFF) # turn on LED linking
125-
self._write_register(_CAP1188_MULTI_TOUCH_CFG, 0x00) # allow multi touch
126-
self._write_register(0x2F, 0x10) # turn off input-1-sets-all-inputs feature
129+
raise RuntimeError(
130+
"Failed to find CAP1188! Product ID: 0x{:02x}".format(pid)
131+
)
132+
self._channels = [None] * 8
133+
self._write_register(_CAP1188_LED_LINKING, 0xFF) # turn on LED linking
134+
self._write_register(_CAP1188_MULTI_TOUCH_CFG, 0x00) # allow multi touch
135+
self._write_register(0x2F, 0x10) # turn off input-1-sets-all-inputs feature
127136
self.recalibrate()
128137

129138
def __getitem__(self, key):
130139
pin = key
131140
index = key - 1
132141
if pin < 1 or pin > 8:
133-
raise IndexError('Pin must be a value 1-8.')
142+
raise IndexError("Pin must be a value 1-8.")
134143
if self._channels[index] is None:
135144
self._channels[index] = CAP1188_Channel(self, pin)
136145
return self._channels[index]
@@ -172,7 +181,7 @@ def thresholds(self, value):
172181
value = int(value)
173182
if not 0 <= value <= 127:
174183
raise ValueError("Threshold value must be in range 0 to 127.")
175-
self._write_block(_CAP1188_THESHOLD_1, bytearray((value,)*8))
184+
self._write_block(_CAP1188_THESHOLD_1, bytearray((value,) * 8))
176185

177186
def threshold_values(self):
178187
"""Return tuple of touch threshold values for all channels."""
@@ -185,9 +194,9 @@ def recalibrate(self):
185194
def delta_count(self, pin):
186195
"""Return the 8 bit delta count value for the channel."""
187196
if pin < 1 or pin > 8:
188-
raise IndexError('Pin must be a value 1-8.')
197+
raise IndexError("Pin must be a value 1-8.")
189198
# 8 bit 2's complement
190-
raw_value = self._read_register(_CAP1188_DELTA_COUNT[pin-1])
199+
raw_value = self._read_register(_CAP1188_DELTA_COUNT[pin - 1])
191200
raw_value = raw_value - 256 if raw_value & 128 else raw_value
192201
return raw_value
193202

adafruit_cap1188/i2c.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@
5050
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_CAP1188.git"
5151

5252
# pylint: disable=bad-whitespace
53-
_CAP1188_DEFAULT_ADDRESS = const(0x29)
53+
_CAP1188_DEFAULT_ADDRESS = const(0x29)
5454
# pylint: enable=bad-whitespace
5555

56+
5657
class CAP1188_I2C(CAP1188):
5758
"""Driver for the CAP1188 connected over I2C."""
59+
5860
def __init__(self, i2c, address=_CAP1188_DEFAULT_ADDRESS):
5961
self._i2c = i2c_device.I2CDevice(i2c, address)
6062
self._buf = bytearray(2)

adafruit_cap1188/spi.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,15 @@
5050
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_CAP1188.git"
5151

5252
# pylint: disable=bad-whitespace
53-
_CAP1188_SPI_SET_ADDR = const(0x7D)
54-
_CAP1188_SPI_WRITE_DATA = const(0x7E)
55-
_CAP1188_SPI_READ_DATA = const(0x7F)
53+
_CAP1188_SPI_SET_ADDR = const(0x7D)
54+
_CAP1188_SPI_WRITE_DATA = const(0x7E)
55+
_CAP1188_SPI_READ_DATA = const(0x7F)
5656
# pylint: enable=bad-whitespace
5757

58+
5859
class CAP1188_SPI(CAP1188):
5960
"""Driver for the CAP1188 connected over SPI."""
61+
6062
def __init__(self, spi, cs):
6163
self._spi = spi_device.SPIDevice(spi, cs)
6264
self._buf = bytearray(4)
@@ -88,7 +90,7 @@ def _read_block(self, start, length):
8890
self._buf[0] = _CAP1188_SPI_SET_ADDR
8991
self._buf[1] = start
9092
self._buf[2] = _CAP1188_SPI_READ_DATA
91-
result = bytearray((_CAP1188_SPI_READ_DATA,)*length)
93+
result = bytearray((_CAP1188_SPI_READ_DATA,) * length)
9294
with self._spi as spi:
9395
spi.write(self._buf, end=3)
9496
spi.write_readinto(result, result)

docs/conf.py

+76-50
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,61 @@
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.napoleon',
16-
'sphinx.ext.todo',
14+
"sphinx.ext.autodoc",
15+
"sphinx.ext.intersphinx",
16+
"sphinx.ext.napoleon",
17+
"sphinx.ext.todo",
1718
]
1819

1920
# Uncomment the below if you use native CircuitPython modules such as
2021
# digitalio, micropython and busio. List the modules you use. Without it, the
2122
# autodoc module docs will fail to generate with a warning.
22-
#autodoc_mock_imports = ["digitalio", "busio", "micropython"]
23-
24-
25-
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None),'Register': ('https://circuitpython.readthedocs.io/projects/register/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
23+
# autodoc_mock_imports = ["digitalio", "busio", "micropython"]
24+
25+
26+
intersphinx_mapping = {
27+
"python": ("https://docs.python.org/3.4", None),
28+
"BusDevice": (
29+
"https://circuitpython.readthedocs.io/projects/busdevice/en/latest/",
30+
None,
31+
),
32+
"Register": (
33+
"https://circuitpython.readthedocs.io/projects/register/en/latest/",
34+
None,
35+
),
36+
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
37+
}
2638

2739
# Add any paths that contain templates here, relative to this directory.
28-
templates_path = ['_templates']
40+
templates_path = ["_templates"]
2941

30-
source_suffix = '.rst'
42+
source_suffix = ".rst"
3143

3244
# The master toctree document.
33-
master_doc = 'index'
45+
master_doc = "index"
3446

3547
# General information about the project.
36-
project = u'Adafruit CAP1188 Library'
37-
copyright = u'2018 Carter Nelson'
38-
author = u'Carter Nelson'
48+
project = u"Adafruit CAP1188 Library"
49+
copyright = u"2018 Carter Nelson"
50+
author = u"Carter Nelson"
3951

4052
# The version info for the project you're documenting, acts as replacement for
4153
# |version| and |release|, also used in various other places throughout the
4254
# built documents.
4355
#
4456
# The short X.Y version.
45-
version = u'1.0'
57+
version = u"1.0"
4658
# The full version, including alpha/beta/rc tags.
47-
release = u'1.0'
59+
release = u"1.0"
4860

4961
# The language for content autogenerated by Sphinx. Refer to documentation
5062
# for a list of supported languages.
@@ -56,7 +68,7 @@
5668
# List of patterns, relative to source directory, that match files and
5769
# directories to ignore when looking for source files.
5870
# This patterns also effect to html_static_path and html_extra_path
59-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
71+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
6072

6173
# The reST default role (used for this markup: `text`) to use for all
6274
# documents.
@@ -68,7 +80,7 @@
6880
add_function_parentheses = True
6981

7082
# The name of the Pygments (syntax highlighting) style to use.
71-
pygments_style = 'sphinx'
83+
pygments_style = "sphinx"
7284

7385
# If true, `todo` and `todoList` produce output, else they produce nothing.
7486
todo_include_todos = False
@@ -83,68 +95,76 @@
8395
# The theme to use for HTML and HTML Help pages. See the documentation for
8496
# a list of builtin themes.
8597
#
86-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
98+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
8799

88100
if not on_rtd: # only import and set the theme if we're building docs locally
89101
try:
90102
import sphinx_rtd_theme
91-
html_theme = 'sphinx_rtd_theme'
92-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
103+
104+
html_theme = "sphinx_rtd_theme"
105+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
93106
except:
94-
html_theme = 'default'
95-
html_theme_path = ['.']
107+
html_theme = "default"
108+
html_theme_path = ["."]
96109
else:
97-
html_theme_path = ['.']
110+
html_theme_path = ["."]
98111

99112
# Add any paths that contain custom static files (such as style sheets) here,
100113
# relative to this directory. They are copied after the builtin static files,
101114
# so a file named "default.css" will overwrite the builtin "default.css".
102-
html_static_path = ['_static']
115+
html_static_path = ["_static"]
103116

104117
# The name of an image file (relative to this directory) to use as a favicon of
105118
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
106119
# pixels large.
107120
#
108-
html_favicon = '_static/favicon.ico'
121+
html_favicon = "_static/favicon.ico"
109122

110123
# Output file base name for HTML help builder.
111-
htmlhelp_basename = 'AdafruitCap1188Librarydoc'
124+
htmlhelp_basename = "AdafruitCap1188Librarydoc"
112125

113126
# -- Options for LaTeX output ---------------------------------------------
114127

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

133143
# Grouping the document tree into LaTeX files. List of tuples
134144
# (source start file, target name, title,
135145
# author, documentclass [howto, manual, or own class]).
136146
latex_documents = [
137-
(master_doc, 'AdafruitCAP1188Library.tex', u'AdafruitCAP1188 Library Documentation',
138-
author, 'manual'),
147+
(
148+
master_doc,
149+
"AdafruitCAP1188Library.tex",
150+
u"AdafruitCAP1188 Library Documentation",
151+
author,
152+
"manual",
153+
),
139154
]
140155

141156
# -- Options for manual page output ---------------------------------------
142157

143158
# One entry per manual page. List of tuples
144159
# (source start file, name, description, authors, manual section).
145160
man_pages = [
146-
(master_doc, 'AdafruitCAP1188library', u'Adafruit CAP1188 Library Documentation',
147-
[author], 1)
161+
(
162+
master_doc,
163+
"AdafruitCAP1188library",
164+
u"Adafruit CAP1188 Library Documentation",
165+
[author],
166+
1,
167+
)
148168
]
149169

150170
# -- Options for Texinfo output -------------------------------------------
@@ -153,7 +173,13 @@
153173
# (source start file, target name, title, author,
154174
# dir menu entry, description, category)
155175
texinfo_documents = [
156-
(master_doc, 'AdafruitCAP1188Library', u'Adafruit CAP1188 Library Documentation',
157-
author, 'AdafruitCAP1188Library', 'One line description of project.',
158-
'Miscellaneous'),
176+
(
177+
master_doc,
178+
"AdafruitCAP1188Library",
179+
u"Adafruit CAP1188 Library Documentation",
180+
author,
181+
"AdafruitCAP1188Library",
182+
"One line description of project.",
183+
"Miscellaneous",
184+
),
159185
]

0 commit comments

Comments
 (0)