Skip to content

Commit 6057386

Browse files
committed
Ran black, updated to pylint 2.x
1 parent d46e205 commit 6057386

File tree

5 files changed

+107
-92
lines changed

5 files changed

+107
-92
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_tfmini.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,16 @@
4545
__version__ = "0.0.0-auto.0"
4646
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_TFmini.git"
4747

48-
_STARTCONFIG = b'\x42\x57\x02\x00\x00\x00\x01\x02'
49-
_STARTREPLY = b'\x57\x02\x01\x00\x00\x01\x02' # minus header 0x42
50-
_CONFIGPARAM = b'\x42\x57\x02\x00'
51-
_ENDCONFIG = b'\x42\x57\x02\x00\x00\x00\x00\x02'
52-
_ENDREPLY = b'\x42\x57\x02\x01\x00\x00\x00\x02'
48+
_STARTCONFIG = b"\x42\x57\x02\x00\x00\x00\x01\x02"
49+
_STARTREPLY = b"\x57\x02\x01\x00\x00\x01\x02" # minus header 0x42
50+
_CONFIGPARAM = b"\x42\x57\x02\x00"
51+
_ENDCONFIG = b"\x42\x57\x02\x00\x00\x00\x00\x02"
52+
_ENDREPLY = b"\x42\x57\x02\x01\x00\x00\x00\x02"
5353

5454
MODE_SHORT = 2
5555
MODE_LONG = 7
5656

57+
5758
class TFmini:
5859
"""TF mini communication module, use with just RX or TX+RX for advanced
5960
command & control.
@@ -87,7 +88,9 @@ def distance(self):
8788
# get remaining packet
8889
data = self._uart.read(8)
8990
# check first byte is magicbyte
90-
frame, dist, self._strength, self._mode, _, checksum = struct.unpack("<BHHBBB", data)
91+
frame, dist, self._strength, self._mode, _, checksum = struct.unpack(
92+
"<BHHBBB", data
93+
)
9194
# look for second 0x59 frame indicator
9295
if frame != 0x59:
9396
continue
@@ -127,24 +130,24 @@ def _set_config(self, command):
127130
if not x or x[0] != 0x42:
128131
continue
129132
echo = self._uart.read(len(_STARTREPLY))
130-
#print("start ", [hex(i) for i in echo])
133+
# print("start ", [hex(i) for i in echo])
131134
if echo != _STARTREPLY:
132135
raise RuntimeError("Did not receive config start echo")
133136
break
134137

135138
# Finally, send the command
136139
self._uart.write(command)
137-
#print([hex(i) for i in command])
140+
# print([hex(i) for i in command])
138141
echo = self._uart.read(len(command))
139142
cmdreply = bytearray(len(command))
140143
cmdreply[:] = command
141144
cmdreply[3] = 0x1
142-
#print("cmd ", [hex(i) for i in echo])
145+
# print("cmd ", [hex(i) for i in echo])
143146
if echo != cmdreply:
144147
raise RuntimeError("Did not receive config command echo")
145148

146149
self._uart.write(_ENDCONFIG)
147150
echo = self._uart.read(len(_ENDREPLY))
148-
#print("end ", [hex(i) for i in echo])
151+
# print("end ", [hex(i) for i in echo])
149152
if echo != _ENDREPLY:
150153
raise RuntimeError("Did not receive config end echo")

docs/conf.py

Lines changed: 65 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,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 TFmini Library'
38-
copyright = u'2018 ladyada'
39-
author = u'ladyada'
41+
project = u"Adafruit TFmini Library"
42+
copyright = u"2018 ladyada"
43+
author = u"ladyada"
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 = u"1.0"
4751
# The full version, including alpha/beta/rc tags.
48-
release = u'1.0'
52+
release = u"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 = 'AdafruitTfminiLibrarydoc'
117+
htmlhelp_basename = "AdafruitTfminiLibrarydoc"
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, 'AdafruitTFminiLibrary.tex', u'AdafruitTFmini Library Documentation',
139-
author, 'manual'),
140+
(
141+
master_doc,
142+
"AdafruitTFminiLibrary.tex",
143+
u"AdafruitTFmini 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, 'AdafruitTFminilibrary', u'Adafruit TFmini Library Documentation',
148-
[author], 1)
154+
(
155+
master_doc,
156+
"AdafruitTFminilibrary",
157+
u"Adafruit TFmini 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, 'AdafruitTFminiLibrary', u'Adafruit TFmini Library Documentation',
158-
author, 'AdafruitTFminiLibrary', 'One line description of project.',
159-
'Miscellaneous'),
169+
(
170+
master_doc,
171+
"AdafruitTFminiLibrary",
172+
u"Adafruit TFmini Library Documentation",
173+
author,
174+
"AdafruitTFminiLibrary",
175+
"One line description of project.",
176+
"Miscellaneous",
177+
),
160178
]

examples/tfmini_simpletest.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
uart = busio.UART(board.TX, board.RX)
88

99
# Or, you can use pyserial on any computer
10-
#import serial
11-
#uart = serial.Serial("/dev/ttyS2", timeout=1)
10+
# import serial
11+
# uart = serial.Serial("/dev/ttyS2", timeout=1)
1212

1313
# Simplest use, connect with the uart bus object
1414
tfmini = adafruit_tfmini.TFmini(uart)
@@ -18,6 +18,8 @@
1818
print("Now in mode", tfmini.mode)
1919

2020
while True:
21-
print("Distance: %d cm (strength %d, mode %x)" %
22-
(tfmini.distance, tfmini.strength, tfmini.mode))
21+
print(
22+
"Distance: %d cm (strength %d, mode %x)"
23+
% (tfmini.distance, tfmini.strength, tfmini.mode)
24+
)
2325
time.sleep(0.1)

setup.py

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,54 +7,46 @@
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-tfmini',
22-
22+
name="adafruit-circuitpython-tfmini",
2323
use_scm_version=True,
24-
setup_requires=['setuptools_scm'],
25-
26-
description='A CircuitPython/Python library for Benewake`s TF mini distance sensor',
24+
setup_requires=["setuptools_scm"],
25+
description="A CircuitPython/Python library for Benewake`s TF mini distance sensor",
2726
long_description=long_description,
28-
long_description_content_type='text/x-rst',
29-
27+
long_description_content_type="text/x-rst",
3028
# The project's main homepage.
31-
url='https://github.com/adafruit/Adafruit_CircuitPython_TFmini',
32-
29+
url="https://github.com/adafruit/Adafruit_CircuitPython_TFmini",
3330
# Author details
34-
author='Adafruit Industries',
35-
author_email='[email protected]',
36-
37-
install_requires=['Adafruit-Blinka', 'pyserial'],
38-
31+
author="Adafruit Industries",
32+
author_email="[email protected]",
33+
install_requires=["Adafruit-Blinka", "pyserial"],
3934
# Choose your license
40-
license='MIT',
41-
35+
license="MIT",
4236
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
4337
classifiers=[
44-
'Development Status :: 3 - Alpha',
45-
'Intended Audience :: Developers',
46-
'Topic :: Software Development :: Libraries',
47-
'Topic :: System :: Hardware',
48-
'License :: OSI Approved :: MIT License',
49-
'Programming Language :: Python :: 3',
50-
'Programming Language :: Python :: 3.4',
51-
'Programming Language :: Python :: 3.5',
38+
"Development Status :: 3 - Alpha",
39+
"Intended Audience :: Developers",
40+
"Topic :: Software Development :: Libraries",
41+
"Topic :: System :: Hardware",
42+
"License :: OSI Approved :: MIT License",
43+
"Programming Language :: Python :: 3",
44+
"Programming Language :: Python :: 3.4",
45+
"Programming Language :: Python :: 3.5",
5246
],
53-
5447
# What does your project relate to?
55-
keywords='adafruit tfmini benewake distance sensor hardware micropython circuitpython',
56-
48+
keywords="adafruit tfmini benewake distance sensor hardware micropython circuitpython",
5749
# You can just specify the packages manually here if your project is
5850
# simple. Or you can use find_packages().
59-
py_modules=['adafruit_tfmini'],
60-
)
51+
py_modules=["adafruit_tfmini"],
52+
)

0 commit comments

Comments
 (0)