Skip to content

Commit dfcdbaa

Browse files
authored
Merge pull request #18 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents 5210dbd + 11e33ea commit dfcdbaa

File tree

4 files changed

+121
-88
lines changed

4 files changed

+121
-88
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_servokit.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,19 @@ class ServoKit:
7676
Default reference clock speed is ``25000000``.
7777
7878
"""
79-
def __init__(self, *, channels, i2c=None, address=0x40, reference_clock_speed=25000000):
79+
80+
def __init__(
81+
self, *, channels, i2c=None, address=0x40, reference_clock_speed=25000000
82+
):
8083
if channels not in [8, 16]:
8184
raise ValueError("servo_channels must be 8 or 16!")
8285
self._items = [None] * channels
8386
self._channels = channels
8487
if i2c is None:
8588
i2c = board.I2C()
86-
self._pca = PCA9685(i2c, address=address, reference_clock_speed=reference_clock_speed)
89+
self._pca = PCA9685(
90+
i2c, address=address, reference_clock_speed=reference_clock_speed
91+
)
8792
self._pca.frequency = 50
8893

8994
self._servo = _Servo(self)
@@ -141,7 +146,8 @@ def __init__(self, kit):
141146
self.kit = kit
142147

143148
def __getitem__(self, servo_channel):
144-
import adafruit_motor.servo
149+
import adafruit_motor.servo # pylint: disable=import-outside-toplevel
150+
145151
num_channels = self.kit._channels
146152
if servo_channel >= num_channels or servo_channel < 0:
147153
raise ValueError("servo must be 0-{}!".format(num_channels - 1))
@@ -164,16 +170,21 @@ def __init__(self, kit):
164170
self.kit = kit
165171

166172
def __getitem__(self, servo_channel):
167-
import adafruit_motor.servo
173+
import adafruit_motor.servo # pylint: disable=import-outside-toplevel
174+
168175
num_channels = self.kit._channels
169176
if servo_channel >= num_channels or servo_channel < 0:
170177
raise ValueError("servo must be 0-{}!".format(num_channels - 1))
171178
servo = self.kit._items[servo_channel]
172179
if servo is None:
173-
servo = adafruit_motor.servo.ContinuousServo(self.kit._pca.channels[servo_channel])
180+
servo = adafruit_motor.servo.ContinuousServo(
181+
self.kit._pca.channels[servo_channel]
182+
)
174183
self.kit._items[servo_channel] = servo
175184
return servo
176-
if isinstance(self.kit._items[servo_channel], adafruit_motor.servo.ContinuousServo):
185+
if isinstance(
186+
self.kit._items[servo_channel], adafruit_motor.servo.ContinuousServo
187+
):
177188
return servo
178189
raise ValueError("Channel {} is already in use.".format(servo_channel))
179190

docs/conf.py

Lines changed: 73 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,40 @@
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),'Register': ('https://circuitpython.readthedocs.io/projects/register/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+
"Register": (
34+
"https://circuitpython.readthedocs.io/projects/register/en/latest/",
35+
None,
36+
),
37+
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
38+
}
2739

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

31-
source_suffix = '.rst'
43+
source_suffix = ".rst"
3244

3345
# The master toctree document.
34-
master_doc = 'index'
46+
master_doc = "index"
3547

3648
# General information about the project.
37-
project = u'Adafruit ServoKit Library'
38-
copyright = u'2018 Kattni Rembor'
39-
author = u'Kattni Rembor'
49+
project = u"Adafruit ServoKit Library"
50+
copyright = u"2018 Kattni Rembor"
51+
author = u"Kattni Rembor"
4052

4153
# The version info for the project you're documenting, acts as replacement for
4254
# |version| and |release|, also used in various other places throughout the
4355
# built documents.
4456
#
4557
# The short X.Y version.
46-
version = u'1.0'
58+
version = u"1.0"
4759
# The full version, including alpha/beta/rc tags.
48-
release = u'1.0'
60+
release = u"1.0"
4961

5062
# The language for content autogenerated by Sphinx. Refer to documentation
5163
# for a list of supported languages.
@@ -57,7 +69,7 @@
5769
# List of patterns, relative to source directory, that match files and
5870
# directories to ignore when looking for source files.
5971
# 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']
72+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
6173

6274
# The reST default role (used for this markup: `text`) to use for all
6375
# documents.
@@ -69,7 +81,7 @@
6981
add_function_parentheses = True
7082

7183
# The name of the Pygments (syntax highlighting) style to use.
72-
pygments_style = 'sphinx'
84+
pygments_style = "sphinx"
7385

7486
# If true, `todo` and `todoList` produce output, else they produce nothing.
7587
todo_include_todos = False
@@ -84,68 +96,76 @@
8496
# The theme to use for HTML and HTML Help pages. See the documentation for
8597
# a list of builtin themes.
8698
#
87-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
99+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
88100

89101
if not on_rtd: # only import and set the theme if we're building docs locally
90102
try:
91103
import sphinx_rtd_theme
92-
html_theme = 'sphinx_rtd_theme'
93-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
104+
105+
html_theme = "sphinx_rtd_theme"
106+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
94107
except:
95-
html_theme = 'default'
96-
html_theme_path = ['.']
108+
html_theme = "default"
109+
html_theme_path = ["."]
97110
else:
98-
html_theme_path = ['.']
111+
html_theme_path = ["."]
99112

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

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

111124
# Output file base name for HTML help builder.
112-
htmlhelp_basename = 'AdafruitServokitLibrarydoc'
125+
htmlhelp_basename = "AdafruitServokitLibrarydoc"
113126

114127
# -- Options for LaTeX output ---------------------------------------------
115128

116129
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',
130+
# The paper size ('letterpaper' or 'a4paper').
131+
#
132+
# 'papersize': 'letterpaper',
133+
# The font size ('10pt', '11pt' or '12pt').
134+
#
135+
# 'pointsize': '10pt',
136+
# Additional stuff for the LaTeX preamble.
137+
#
138+
# 'preamble': '',
139+
# Latex figure (float) alignment
140+
#
141+
# 'figure_align': 'htbp',
132142
}
133143

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

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

144159
# One entry per manual page. List of tuples
145160
# (source start file, name, description, authors, manual section).
146161
man_pages = [
147-
(master_doc, 'AdafruitServoKitlibrary', u'Adafruit ServoKit Library Documentation',
148-
[author], 1)
162+
(
163+
master_doc,
164+
"AdafruitServoKitlibrary",
165+
u"Adafruit ServoKit Library Documentation",
166+
[author],
167+
1,
168+
)
149169
]
150170

151171
# -- Options for Texinfo output -------------------------------------------
@@ -154,7 +174,13 @@
154174
# (source start file, target name, title, author,
155175
# dir menu entry, description, category)
156176
texinfo_documents = [
157-
(master_doc, 'AdafruitServoKitLibrary', u'Adafruit ServoKit Library Documentation',
158-
author, 'AdafruitServoKitLibrary', 'One line description of project.',
159-
'Miscellaneous'),
177+
(
178+
master_doc,
179+
"AdafruitServoKitLibrary",
180+
u"Adafruit ServoKit Library Documentation",
181+
author,
182+
"AdafruitServoKitLibrary",
183+
"One line description of project.",
184+
"Miscellaneous",
185+
),
160186
]

setup.py

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,58 +7,54 @@
77

88
# Always prefer setuptools over distutils
99
from setuptools import setup, find_packages
10+
1011
# To use a consistent encoding
1112
from codecs import open
1213
from os import path
1314

1415
here = path.abspath(path.dirname(__file__))
1516

1617
# Get the long description from the README file
17-
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
18+
with open(path.join(here, "README.rst"), encoding="utf-8") as f:
1819
long_description = f.read()
1920

2021
setup(
21-
name='adafruit-circuitpython-servokit',
22-
22+
name="adafruit-circuitpython-servokit",
2323
use_scm_version=True,
24-
setup_requires=['setuptools_scm'],
25-
26-
description='CircuitPython helper library for PWM/Servo FeatherWing, Shield, and '
27-
'Pi HAT and Bonnet kits.',
24+
setup_requires=["setuptools_scm"],
25+
description="CircuitPython helper library for PWM/Servo FeatherWing, Shield, and "
26+
"Pi HAT and Bonnet kits.",
2827
long_description=long_description,
29-
long_description_content_type='text/x-rst',
30-
28+
long_description_content_type="text/x-rst",
3129
# The project's main homepage.
32-
url='https://github.com/adafruit/Adafruit_CircuitPython_ServoKit',
33-
30+
url="https://github.com/adafruit/Adafruit_CircuitPython_ServoKit",
3431
# Author details
35-
author='Adafruit Industries',
36-
author_email='[email protected]',
37-
38-
install_requires=['Adafruit-Blinka', 'adafruit-circuitpython-busdevice',
39-
'adafruit-circuitpython-register', 'adafruit-circuitpython-pca9685',
40-
'adafruit-circuitpython-motor'],
41-
32+
author="Adafruit Industries",
33+
author_email="[email protected]",
34+
install_requires=[
35+
"Adafruit-Blinka",
36+
"adafruit-circuitpython-busdevice",
37+
"adafruit-circuitpython-register",
38+
"adafruit-circuitpython-pca9685",
39+
"adafruit-circuitpython-motor",
40+
],
4241
# Choose your license
43-
license='MIT',
44-
42+
license="MIT",
4543
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
4644
classifiers=[
47-
'Development Status :: 3 - Alpha',
48-
'Intended Audience :: Developers',
49-
'Topic :: Software Development :: Libraries',
50-
'Topic :: System :: Hardware',
51-
'License :: OSI Approved :: MIT License',
52-
'Programming Language :: Python :: 3',
53-
'Programming Language :: Python :: 3.4',
54-
'Programming Language :: Python :: 3.5',
45+
"Development Status :: 3 - Alpha",
46+
"Intended Audience :: Developers",
47+
"Topic :: Software Development :: Libraries",
48+
"Topic :: System :: Hardware",
49+
"License :: OSI Approved :: MIT License",
50+
"Programming Language :: Python :: 3",
51+
"Programming Language :: Python :: 3.4",
52+
"Programming Language :: Python :: 3.5",
5553
],
56-
5754
# What does your project relate to?
58-
keywords='adafruit servo motor pwm pca9685 featherwing pi shield bonnet servokit kit i2c '
59-
'hardware micropython circuitpython',
60-
55+
keywords="adafruit servo motor pwm pca9685 featherwing pi shield bonnet servokit kit i2c "
56+
"hardware micropython circuitpython",
6157
# You can just specify the packages manually here if your project is
6258
# simple. Or you can use find_packages().
63-
py_modules=['adafruit_servokit'],
64-
)
59+
py_modules=["adafruit_servokit"],
60+
)

0 commit comments

Comments
 (0)