Skip to content

Commit e483b6e

Browse files
authored
Merge pull request #3 from adafruit/pylint-update
Pylint update
2 parents 29051f2 + 8291cb8 commit e483b6e

File tree

6 files changed

+111
-92
lines changed

6 files changed

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

adafruit_wsgi/request.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@
2929
"""
3030
import re
3131

32-
class Request():
32+
33+
class Request:
3334
"""
3435
An incoming HTTP request.
3536
A higher level abstraction of the raw WSGI Environ dictionary.
3637
"""
38+
3739
def __init__(self, environ):
3840
self._method = environ["REQUEST_METHOD"]
3941
self._path = environ["PATH_INFO"]
@@ -107,7 +109,7 @@ def __parse_headers(environ):
107109
if "CONTENT_LENGTH" in environ:
108110
headers["content-length"] = environ["CONTENT_LENGTH"]
109111

110-
env_header_re = re.compile(r'HTTP_(.+)')
112+
env_header_re = re.compile(r"HTTP_(.+)")
111113
for key, val in environ.items():
112114
header = env_header_re.match(key)
113115
if header:

adafruit_wsgi/wsgi_app.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
__version__ = "0.0.0-auto.0"
5151
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_WSGI.git"
5252

53+
5354
class WSGIApp:
5455
"""
5556
The base WSGI Application class.
@@ -106,16 +107,18 @@ def on_request(self, methods, rule, request_handler):
106107
regex += r"([a-zA-Z0-9_-]+)\/"
107108
else:
108109
regex += part + r"\/"
109-
regex += "?$" # make last slash optional and that we only allow full matches
110-
self._routes.append((re.compile(regex), {"methods": methods, "func": request_handler}))
110+
regex += "?$" # make last slash optional and that we only allow full matches
111+
self._routes.append(
112+
(re.compile(regex), {"methods": methods, "func": request_handler})
113+
)
111114

112115
def route(self, rule, methods=None):
113116
"""
114117
A decorator to register a route rule with an endpoint function.
115118
if no methods are provided, default to GET
116119
"""
117120
if not methods:
118-
methods = ['GET']
121+
methods = ["GET"]
119122
return lambda func: self.on_request(methods, rule, func)
120123

121124
def _match_route(self, path, method):

docs/conf.py

+65-47
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,32 @@
2324
# autodoc_mock_imports = ["digitalio", "busio"]
2425

2526

26-
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
27+
intersphinx_mapping = {
28+
"python": ("https://docs.python.org/3.4", None),
29+
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
30+
}
2731

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

31-
source_suffix = '.rst'
35+
source_suffix = ".rst"
3236

3337
# The master toctree document.
34-
master_doc = 'index'
38+
master_doc = "index"
3539

3640
# General information about the project.
37-
project = u'Adafruit WSGI Library'
38-
copyright = u'2019 Matthew Costi'
39-
author = u'Matthew Costi'
41+
project = "Adafruit WSGI Library"
42+
copyright = "2019 Matthew Costi"
43+
author = "Matthew Costi"
4044

4145
# The version info for the project you're documenting, acts as replacement for
4246
# |version| and |release|, also used in various other places throughout the
4347
# built documents.
4448
#
4549
# The short X.Y version.
46-
version = u'1.0'
50+
version = "1.0"
4751
# The full version, including alpha/beta/rc tags.
48-
release = u'1.0'
52+
release = "1.0"
4953

5054
# The language for content autogenerated by Sphinx. Refer to documentation
5155
# for a list of supported languages.
@@ -57,7 +61,7 @@
5761
# List of patterns, relative to source directory, that match files and
5862
# directories to ignore when looking for source files.
5963
# 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']
64+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
6165

6266
# The reST default role (used for this markup: `text`) to use for all
6367
# documents.
@@ -69,7 +73,7 @@
6973
add_function_parentheses = True
7074

7175
# The name of the Pygments (syntax highlighting) style to use.
72-
pygments_style = 'sphinx'
76+
pygments_style = "sphinx"
7377

7478
# If true, `todo` and `todoList` produce output, else they produce nothing.
7579
todo_include_todos = False
@@ -84,68 +88,76 @@
8488
# The theme to use for HTML and HTML Help pages. See the documentation for
8589
# a list of builtin themes.
8690
#
87-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
91+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
8892

8993
if not on_rtd: # only import and set the theme if we're building docs locally
9094
try:
9195
import sphinx_rtd_theme
92-
html_theme = 'sphinx_rtd_theme'
93-
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(), "."]
9499
except:
95-
html_theme = 'default'
96-
html_theme_path = ['.']
100+
html_theme = "default"
101+
html_theme_path = ["."]
97102
else:
98-
html_theme_path = ['.']
103+
html_theme_path = ["."]
99104

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

105110
# The name of an image file (relative to this directory) to use as a favicon of
106111
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
107112
# pixels large.
108113
#
109-
html_favicon = '_static/favicon.ico'
114+
html_favicon = "_static/favicon.ico"
110115

111116
# Output file base name for HTML help builder.
112-
htmlhelp_basename = 'AdafruitWsgiLibrarydoc'
117+
htmlhelp_basename = "AdafruitWsgiLibrarydoc"
113118

114119
# -- Options for LaTeX output ---------------------------------------------
115120

116121
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',
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',
132134
}
133135

134136
# Grouping the document tree into LaTeX files. List of tuples
135137
# (source start file, target name, title,
136138
# author, documentclass [howto, manual, or own class]).
137139
latex_documents = [
138-
(master_doc, 'AdafruitWSGILibrary.tex', u'AdafruitWSGI Library Documentation',
139-
author, 'manual'),
140+
(
141+
master_doc,
142+
"AdafruitWSGILibrary.tex",
143+
"AdafruitWSGI Library Documentation",
144+
author,
145+
"manual",
146+
),
140147
]
141148

142149
# -- Options for manual page output ---------------------------------------
143150

144151
# One entry per manual page. List of tuples
145152
# (source start file, name, description, authors, manual section).
146153
man_pages = [
147-
(master_doc, 'AdafruitWSGIlibrary', u'Adafruit WSGI Library Documentation',
148-
[author], 1)
154+
(
155+
master_doc,
156+
"AdafruitWSGIlibrary",
157+
"Adafruit WSGI Library Documentation",
158+
[author],
159+
1,
160+
)
149161
]
150162

151163
# -- Options for Texinfo output -------------------------------------------
@@ -154,7 +166,13 @@
154166
# (source start file, target name, title, author,
155167
# dir menu entry, description, category)
156168
texinfo_documents = [
157-
(master_doc, 'AdafruitWSGILibrary', u'Adafruit WSGI Library Documentation',
158-
author, 'AdafruitWSGILibrary', 'One line description of project.',
159-
'Miscellaneous'),
169+
(
170+
master_doc,
171+
"AdafruitWSGILibrary",
172+
"Adafruit WSGI Library Documentation",
173+
author,
174+
"AdafruitWSGILibrary",
175+
"One line description of project.",
176+
"Miscellaneous",
177+
),
160178
]

examples/wsgi_simpletest.py

+13-7
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,20 @@
3232
# esp32_reset = DigitalInOut(board.D5)
3333

3434
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
35-
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset) # pylint: disable=line-too-long
35+
esp = adafruit_esp32spi.ESP_SPIcontrol(
36+
spi, esp32_cs, esp32_ready, esp32_reset
37+
) # pylint: disable=line-too-long
3638

3739
"""Use below for Most Boards"""
38-
status_light = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.2) # Uncomment for Most Boards
40+
status_light = neopixel.NeoPixel(
41+
board.NEOPIXEL, 1, brightness=0.2
42+
) # Uncomment for Most Boards
3943
"""Uncomment below for ItsyBitsy M4"""
4044
# import adafruit_dotstar as dotstar
4145
# status_light = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=1)
4246

4347
## If you want to connect to wifi with secrets:
44-
wifi = wifimanager.ESPSPI_WiFiManager(esp, secrets, status_light,debug=True)
48+
wifi = wifimanager.ESPSPI_WiFiManager(esp, secrets, status_light, debug=True)
4549
wifi.connect()
4650

4751
## If you want to create a WIFI hotspot to connect to with secrets:
@@ -59,14 +63,16 @@
5963

6064
web_app = WSGIApp()
6165

62-
@web_app.route('/led_on/<r>/<g>/<b>')
63-
def led_on(request, r, g, b): # pylint: disable=unused-argument
66+
67+
@web_app.route("/led_on/<r>/<g>/<b>")
68+
def led_on(request, r, g, b): # pylint: disable=unused-argument
6469
print("led on!")
6570
status_light.fill((int(r), int(g), int(b)))
6671
return ("200 OK", [], "led on!")
6772

68-
@web_app.route('/led_off')
69-
def led_off(request): # pylint: disable=unused-argument
73+
74+
@web_app.route("/led_off")
75+
def led_off(request): # pylint: disable=unused-argument
7076
print("led off!")
7177
status_light.fill(0)
7278
return ("200 OK", [], "led off!")

setup.py

+22-32
Original file line numberDiff line numberDiff line change
@@ -6,59 +6,49 @@
66
"""
77

88
from setuptools import setup, find_packages
9+
910
# To use a consistent encoding
1011
from codecs import open
1112
from os import path
1213

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

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

1920
setup(
20-
name='adafruit-circuitpython-wsgi',
21-
21+
name="adafruit-circuitpython-wsgi",
2222
use_scm_version=True,
23-
setup_requires=['setuptools_scm'],
24-
25-
description='CircuitPython framework for creating WSGI compatible web server applications.',
23+
setup_requires=["setuptools_scm"],
24+
description="CircuitPython framework for creating WSGI compatible web server applications.",
2625
long_description=long_description,
27-
long_description_content_type='text/x-rst',
28-
26+
long_description_content_type="text/x-rst",
2927
# The project's main homepage.
30-
url='https://github.com/adafruit/Adafruit_CircuitPython_WSGI',
31-
28+
url="https://github.com/adafruit/Adafruit_CircuitPython_WSGI",
3229
# Author details
33-
author='Adafruit Industries',
34-
author_email='[email protected]',
35-
36-
install_requires=[
37-
'Adafruit-Blinka'
38-
],
39-
30+
author="Adafruit Industries",
31+
author_email="[email protected]",
32+
install_requires=["Adafruit-Blinka"],
4033
# Choose your license
41-
license='MIT',
42-
34+
license="MIT",
4335
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
4436
classifiers=[
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',
37+
"Development Status :: 3 - Alpha",
38+
"Intended Audience :: Developers",
39+
"Topic :: Software Development :: Libraries",
40+
"Topic :: System :: Hardware",
41+
"License :: OSI Approved :: MIT License",
42+
"Programming Language :: Python :: 3",
43+
"Programming Language :: Python :: 3.4",
44+
"Programming Language :: Python :: 3.5",
5345
],
54-
5546
# What does your project relate to?
56-
keywords='adafruit blinka circuitpython micropython wsgi web server webserver app webapp '
57-
'framework http https flask',
58-
47+
keywords="adafruit blinka circuitpython micropython wsgi web server webserver app webapp "
48+
"framework http https flask",
5949
# You can just specify the packages manually here if your project is
6050
# simple. Or you can use find_packages().
6151
# TODO: IF LIBRARY FILES ARE A PACKAGE FOLDER,
6252
# CHANGE `py_modules=['...']` TO `packages=['...']`
63-
py_modules=['adafruit_wsgi'],
53+
py_modules=["adafruit_wsgi"],
6454
)

0 commit comments

Comments
 (0)