Skip to content

Commit 2c43c11

Browse files
authored
Merge pull request #4 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents 2a0b413 + bce1d4e commit 2c43c11

File tree

6 files changed

+116
-98
lines changed

6 files changed

+116
-98
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

.pylintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -430,4 +430,4 @@ min-public-methods=1
430430

431431
# Exceptions that will emit a warning when being caught. Defaults to
432432
# "Exception"
433-
overgeneral-exceptions=Exception
433+
overgeneral-exceptions=Exception

adafruit_progressbar.py

+22-11
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,19 @@ class ProgressBar(displayio.TileGrid):
6060
:param int stroke: Used for the outline_color
6161
6262
"""
63-
#pylint: disable=invalid-name
64-
def __init__(self, x, y, width, height,
65-
progress=0.0, bar_color=0x00FF00,
66-
outline_color=0xFFFFFF, stroke=1):
63+
64+
# pylint: disable=invalid-name
65+
def __init__(
66+
self,
67+
x,
68+
y,
69+
width,
70+
height,
71+
progress=0.0,
72+
bar_color=0x00FF00,
73+
outline_color=0xFFFFFF,
74+
stroke=1,
75+
):
6776
assert isinstance(progress, float), "Progress must be a floating point value."
6877
self._bitmap = displayio.Bitmap(width, height, 3)
6978
self._palette = displayio.Palette(3)
@@ -81,11 +90,11 @@ def __init__(self, x, y, width, height,
8190
for _w in range(width):
8291
for line in range(stroke):
8392
self._bitmap[_w, line] = 1
84-
self._bitmap[_w, height-1-line] = 1
93+
self._bitmap[_w, height - 1 - line] = 1
8594
for _h in range(height):
8695
for line in range(stroke):
8796
self._bitmap[line, _h] = 1
88-
self._bitmap[width-1-line, _h] = 1
97+
self._bitmap[width - 1 - line, _h] = 1
8998
super().__init__(self._bitmap, pixel_shader=self._palette, x=x, y=y)
9099

91100
@property
@@ -103,16 +112,18 @@ def progress(self, value):
103112
:param float value: Progress bar value.
104113
"""
105114
assert value <= 1.0, "Progress value may not be > 100%"
106-
assert isinstance(value, float), "Progress value must be a floating point value."
115+
assert isinstance(
116+
value, float
117+
), "Progress value must be a floating point value."
107118
if self._progress_val > value:
108119
# uncolorize range from width*value+margin to width-margin
109-
for _w in range(int(value*self._width+2), self._width-2):
110-
for _h in range(2, self._height-2):
120+
for _w in range(int(value * self._width + 2), self._width - 2):
121+
for _h in range(2, self._height - 2):
111122
self._bitmap[_w, _h] = 0
112123
else:
113124
# fully fill progress bar color
114-
for _w in range(2, self._width*value-2):
115-
for _h in range(2, self._height-2):
125+
for _w in range(2, self._width * value - 2):
126+
for _h in range(2, self._height - 2):
116127
self._bitmap[_w, _h] = 2
117128
self._progress_val = value
118129

docs/conf.py

+65-47
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,52 @@
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.
2223
autodoc_mock_imports = ["displayio"]
2324

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

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

29-
source_suffix = '.rst'
33+
source_suffix = ".rst"
3034

3135
# The master toctree document.
32-
master_doc = 'index'
36+
master_doc = "index"
3337

3438
# General information about the project.
35-
project = u'Adafruit ProgressBar Library'
36-
copyright = u'2020 Brent Rubell'
37-
author = u'Brent Rubell'
39+
project = u"Adafruit ProgressBar Library"
40+
copyright = u"2020 Brent Rubell"
41+
author = u"Brent Rubell"
3842

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

4852
# The language for content autogenerated by Sphinx. Refer to documentation
4953
# for a list of supported languages.
@@ -55,7 +59,7 @@
5559
# List of patterns, relative to source directory, that match files and
5660
# directories to ignore when looking for source files.
5761
# This patterns also effect to html_static_path and html_extra_path
58-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
62+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
5963

6064
# The reST default role (used for this markup: `text`) to use for all
6165
# documents.
@@ -67,7 +71,7 @@
6771
add_function_parentheses = True
6872

6973
# The name of the Pygments (syntax highlighting) style to use.
70-
pygments_style = 'sphinx'
74+
pygments_style = "sphinx"
7175

7276
# If true, `todo` and `todoList` produce output, else they produce nothing.
7377
todo_include_todos = False
@@ -82,68 +86,76 @@
8286
# The theme to use for HTML and HTML Help pages. See the documentation for
8387
# a list of builtin themes.
8488
#
85-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
89+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
8690

8791
if not on_rtd: # only import and set the theme if we're building docs locally
8892
try:
8993
import sphinx_rtd_theme
90-
html_theme = 'sphinx_rtd_theme'
91-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
94+
95+
html_theme = "sphinx_rtd_theme"
96+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
9297
except:
93-
html_theme = 'default'
94-
html_theme_path = ['.']
98+
html_theme = "default"
99+
html_theme_path = ["."]
95100
else:
96-
html_theme_path = ['.']
101+
html_theme_path = ["."]
97102

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

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

109114
# Output file base name for HTML help builder.
110-
htmlhelp_basename = 'AdafruitProgressbarLibrarydoc'
115+
htmlhelp_basename = "AdafruitProgressbarLibrarydoc"
111116

112117
# -- Options for LaTeX output ---------------------------------------------
113118

114119
latex_elements = {
115-
# The paper size ('letterpaper' or 'a4paper').
116-
#
117-
# 'papersize': 'letterpaper',
118-
119-
# The font size ('10pt', '11pt' or '12pt').
120-
#
121-
# 'pointsize': '10pt',
122-
123-
# Additional stuff for the LaTeX preamble.
124-
#
125-
# 'preamble': '',
126-
127-
# Latex figure (float) alignment
128-
#
129-
# 'figure_align': 'htbp',
120+
# The paper size ('letterpaper' or 'a4paper').
121+
#
122+
# 'papersize': 'letterpaper',
123+
# The font size ('10pt', '11pt' or '12pt').
124+
#
125+
# 'pointsize': '10pt',
126+
# Additional stuff for the LaTeX preamble.
127+
#
128+
# 'preamble': '',
129+
# Latex figure (float) alignment
130+
#
131+
# 'figure_align': 'htbp',
130132
}
131133

132134
# Grouping the document tree into LaTeX files. List of tuples
133135
# (source start file, target name, title,
134136
# author, documentclass [howto, manual, or own class]).
135137
latex_documents = [
136-
(master_doc, 'AdafruitProgressBarLibrary.tex', u'AdafruitProgressBar Library Documentation',
137-
author, 'manual'),
138+
(
139+
master_doc,
140+
"AdafruitProgressBarLibrary.tex",
141+
u"AdafruitProgressBar Library Documentation",
142+
author,
143+
"manual",
144+
),
138145
]
139146

140147
# -- Options for manual page output ---------------------------------------
141148

142149
# One entry per manual page. List of tuples
143150
# (source start file, name, description, authors, manual section).
144151
man_pages = [
145-
(master_doc, 'AdafruitProgressBarlibrary', u'Adafruit ProgressBar Library Documentation',
146-
[author], 1)
152+
(
153+
master_doc,
154+
"AdafruitProgressBarlibrary",
155+
u"Adafruit ProgressBar Library Documentation",
156+
[author],
157+
1,
158+
)
147159
]
148160

149161
# -- Options for Texinfo output -------------------------------------------
@@ -152,7 +164,13 @@
152164
# (source start file, target name, title, author,
153165
# dir menu entry, description, category)
154166
texinfo_documents = [
155-
(master_doc, 'AdafruitProgressBarLibrary', u'Adafruit ProgressBar Library Documentation',
156-
author, 'AdafruitProgressBarLibrary', 'One line description of project.',
157-
'Miscellaneous'),
167+
(
168+
master_doc,
169+
"AdafruitProgressBarLibrary",
170+
u"Adafruit ProgressBar Library Documentation",
171+
author,
172+
"AdafruitProgressBarLibrary",
173+
"One line description of project.",
174+
"Miscellaneous",
175+
),
158176
]

examples/progressbar_simpletest.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@
1111
color_bitmap = displayio.Bitmap(320, 240, 1)
1212
color_palette = displayio.Palette(1)
1313
color_palette[0] = 0x0
14-
bg_sprite = displayio.TileGrid(color_bitmap, x=0, y=0,
15-
pixel_shader=color_palette)
14+
bg_sprite = displayio.TileGrid(color_bitmap, x=0, y=0, pixel_shader=color_palette)
1615
splash.append(bg_sprite)
1716
##########################################################################
1817

1918
# set progress bar width and height relative to board's display
20-
x = board.DISPLAY.width//5
21-
y = board.DISPLAY.height//3
19+
x = board.DISPLAY.width // 5
20+
y = board.DISPLAY.height // 3
2221

2322
# Create a new progress_bar object at (x, y)
2423
progress_bar = ProgressBar(x, y, 200, 30, 1.0)
@@ -29,9 +28,9 @@
2928
current_progress = 0.0
3029
while True:
3130
while current_progress <= 1.0:
32-
print("Progress: {}%".format(current_progress*100))
31+
print("Progress: {}%".format(current_progress * 100))
3332
progress_bar.progress = current_progress
34-
current_progress+=0.05
33+
current_progress += 0.05
3534
if current_progress >= 1.0:
3635
current_progress = 0.0
3736
time.sleep(0.01)

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-progressbar',
21-
21+
name="adafruit-circuitpython-progressbar",
2222
use_scm_version=True,
23-
setup_requires=['setuptools_scm'],
24-
25-
description='Dynamic progress bar widget for CircuitPython displays',
23+
setup_requires=["setuptools_scm"],
24+
description="Dynamic progress bar widget for CircuitPython displays",
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_ProgressBar',
31-
28+
url="https://github.com/adafruit/Adafruit_CircuitPython_ProgressBar",
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 progressbar widget, displayio, '
57-
'progress, bar, element',
58-
47+
keywords="adafruit blinka circuitpython micropython progressbar widget, displayio, "
48+
"progress, bar, element",
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_progressbar'],
53+
py_modules=["adafruit_progressbar"],
6454
)

0 commit comments

Comments
 (0)