Skip to content

Commit 4eb6e4c

Browse files
committed
Ran black, updated to pylint 2.x
1 parent 12b5fe8 commit 4eb6e4c

File tree

6 files changed

+96
-73
lines changed

6 files changed

+96
-73
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 pylint black==19.10b0 Sphinx sphinx-rtd-theme
4444
- name: Library version
4545
run: git describe --dirty --always --tags
4646
- name: PyLint

adafruit_nunchuk.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
_I2C_INIT_DELAY = 0.1
5353
_I2C_READ_DELAY = 0.01
5454

55+
5556
class Nunchuk:
5657
"""Class which provides interface to Nintendo Nunchuk controller."""
5758

@@ -62,9 +63,9 @@ def __init__(self, i2c, address=_DEFAULT_ADDRESS):
6263
with self.i2c_device as i2c_dev:
6364
# turn off encrypted data
6465
# http://wiibrew.org/wiki/Wiimote/Extension_Controllers
65-
i2c_dev.write(b'\xF0\x55')
66+
i2c_dev.write(b"\xF0\x55")
6667
time.sleep(_I2C_INIT_DELAY)
67-
i2c_dev.write(b'\xFB\x00')
68+
i2c_dev.write(b"\xFB\x00")
6869

6970
@property
7071
def joystick(self):
@@ -73,12 +74,12 @@ def joystick(self):
7374
return self.buffer[0], self.buffer[1]
7475

7576
@property
76-
def button_C(self): #pylint: disable=invalid-name
77+
def button_C(self): # pylint: disable=invalid-name
7778
"""Return current pressed state of button C."""
7879
return not bool(self._read_data()[5] & 0x02)
7980

8081
@property
81-
def button_Z(self): #pylint: disable=invalid-name
82+
def button_Z(self): # pylint: disable=invalid-name
8283
"""Return current pressed state of button Z."""
8384
return not bool(self._read_data()[5] & 0x01)
8485

@@ -95,7 +96,7 @@ def acceleration(self):
9596
return x, y, z
9697

9798
def _read_data(self):
98-
return self._read_register(b'\x00')
99+
return self._read_register(b"\x00")
99100

100101
def _read_register(self, address):
101102
with self.i2c_device as i2c:

docs/conf.py

Lines changed: 69 additions & 47 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',
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
# TODO: Please Read!
@@ -23,29 +24,36 @@
2324
# autodoc_mock_imports = ["digitalio", "busio"]
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 Nunchuk Library'
38-
copyright = u'2019 Carter Nelson'
39-
author = u'Carter Nelson'
45+
project = "Adafruit Nunchuk Library"
46+
copyright = "2019 Carter Nelson"
47+
author = "Carter Nelson"
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 = "1.0"
4755
# The full version, including alpha/beta/rc tags.
48-
release = u'1.0'
56+
release = "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 = 'AdafruitNunchukLibrarydoc'
121+
htmlhelp_basename = "AdafruitNunchukLibrarydoc"
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, 'AdafruitNunchukLibrary.tex', u'AdafruitNunchuk Library Documentation',
139-
author, 'manual'),
144+
(
145+
master_doc,
146+
"AdafruitNunchukLibrary.tex",
147+
"AdafruitNunchuk 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, 'AdafruitNunchuklibrary', u'Adafruit Nunchuk Library Documentation',
148-
[author], 1)
158+
(
159+
master_doc,
160+
"AdafruitNunchuklibrary",
161+
"Adafruit Nunchuk 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, 'AdafruitNunchukLibrary', u'Adafruit Nunchuk Library Documentation',
158-
author, 'AdafruitNunchukLibrary', 'One line description of project.',
159-
'Miscellaneous'),
173+
(
174+
master_doc,
175+
"AdafruitNunchukLibrary",
176+
"Adafruit Nunchuk Library Documentation",
177+
author,
178+
"AdafruitNunchukLibrary",
179+
"One line description of project.",
180+
"Miscellaneous",
181+
),
160182
]

examples/nunchuk_accel_mouse.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,24 @@
1414
cDown = False
1515
zDown = False
1616

17-
#This is to allow double checking (only on left click - and it doesn't really work)
18-
CHECK_COUNT=0
17+
# This is to allow double checking (only on left click - and it doesn't really work)
18+
CHECK_COUNT = 0
1919

2020

21-
#This is just to show that we're getting back data - uncomment it and hold down the buttons
22-
#while True:
21+
# This is just to show that we're getting back data - uncomment it and hold down the buttons
22+
# while True:
2323
# print((0 if nc.button_C else 1, 0 if nc.button_Z else 1))
2424

2525
while True:
2626
accel = nc.acceleration
27-
# print(accel)
28-
# x, y = nc.joystick
29-
# print((x,y))
30-
x = accel[0]/4
31-
y = accel[1]/4
32-
print((x,y))
33-
#Eliminate spurious reads
34-
if (x == 255 or y == 255):
27+
# print(accel)
28+
# x, y = nc.joystick
29+
# print((x,y))
30+
x = accel[0] / 4
31+
y = accel[1] / 4
32+
print((x, y))
33+
# Eliminate spurious reads
34+
if x == 255 or y == 255:
3535
continue
3636
relX = x - centerX
3737
relY = y - centerY

examples/nunchuk_analog_mouse.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@
1414
cDown = False
1515
zDown = False
1616

17-
#This is to allow double checking (only on left click - and it doesn't really work)
18-
CHECK_COUNT=0
17+
# This is to allow double checking (only on left click - and it doesn't really work)
18+
CHECK_COUNT = 0
1919

2020

21-
#This is just to show that we're getting back data - uncomment it and hold down the buttons
22-
#while True:
21+
# This is just to show that we're getting back data - uncomment it and hold down the buttons
22+
# while True:
2323
# print((0 if nc.button_C else 1, 0 if nc.button_Z else 1))
2424

2525
while True:
2626
x, y = nc.joystick
27-
#Eliminate spurious reads
28-
if (x == 255 or y == 255):
27+
# Eliminate spurious reads
28+
if x == 255 or y == 255:
2929
continue
3030
relX = x - centerX
3131
relY = centerY - y

examples/nunchuk_mouse.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
while True:
1111
x, y = nc.joystick
12-
x = (x - 128)//2
13-
y = (128 - y)//2
12+
x = (x - 128) // 2
13+
y = (128 - y) // 2
1414
if abs(x) > THRESHOLD:
1515
m.move(x, 0, 0)
1616
if abs(y) > THRESHOLD:

0 commit comments

Comments
 (0)