Skip to content

Commit ef67074

Browse files
authored
Merge pull request #18 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents 54aa07e + 7023804 commit ef67074

File tree

4 files changed

+96
-84
lines changed

4 files changed

+96
-84
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_hcsr04.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,15 @@
5252
_USE_PULSEIO = False
5353
try:
5454
from pulseio import PulseIn
55+
5556
_USE_PULSEIO = True
5657
except ImportError:
57-
pass # This is OK, we'll try to bitbang it!
58+
pass # This is OK, we'll try to bitbang it!
5859

5960
__version__ = "0.0.0-auto.0"
6061
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_HCSR04.git"
6162

63+
6264
class HCSR04:
6365
"""Control a HC-SR04 ultrasonic range sensor.
6466
@@ -82,6 +84,7 @@ class HCSR04:
8284
pass
8385
time.sleep(0.1)
8486
"""
87+
8588
def __init__(self, trigger_pin, echo_pin, *, timeout=0.1):
8689
"""
8790
:param trigger_pin: The pin on the microcontroller that's connected to the
@@ -142,10 +145,10 @@ def distance(self):
142145

143146
def _dist_two_wire(self):
144147
if _USE_PULSEIO:
145-
self._echo.clear() # Discard any previous pulse values
148+
self._echo.clear() # Discard any previous pulse values
146149
self._trig.value = True # Set trig high
147-
time.sleep(0.00001) # 10 micro seconds 10/1000/1000
148-
self._trig.value = False # Set trig low
150+
time.sleep(0.00001) # 10 micro seconds 10/1000/1000
151+
self._trig.value = False # Set trig low
149152

150153
pulselen = None
151154
timestamp = time.monotonic()
@@ -170,7 +173,7 @@ def _dist_two_wire(self):
170173
if time.monotonic() - timestamp > self._timeout:
171174
raise RuntimeError("Timed out")
172175
pulselen = time.monotonic() - timestamp
173-
pulselen *= 1000000 # convert to us to match pulseio
176+
pulselen *= 1000000 # convert to us to match pulseio
174177
if pulselen >= 65535:
175178
raise RuntimeError("Timed out")
176179

docs/conf.py

Lines changed: 65 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,50 @@
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.viewcode',
14+
"sphinx.ext.autodoc",
15+
"sphinx.ext.intersphinx",
16+
"sphinx.ext.viewcode",
1617
]
1718

18-
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),
19-
'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
19+
intersphinx_mapping = {
20+
"python": ("https://docs.python.org/3.4", None),
21+
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
22+
}
2023

2124
# Show the docstring from both the class and its __init__() method
22-
autoclass_content = 'both'
23-
autodoc_member_order = 'bysource'
25+
autoclass_content = "both"
26+
autodoc_member_order = "bysource"
2427

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

28-
source_suffix = '.rst'
31+
source_suffix = ".rst"
2932

3033
# The master toctree document.
31-
master_doc = 'index'
34+
master_doc = "index"
3235

3336
# General information about the project.
34-
project = u'Adafruit HCSR04 Library'
35-
copyright = u'2017 Mike Mabey'
36-
author = u'Mike Mabey'
37+
project = u"Adafruit HCSR04 Library"
38+
copyright = u"2017 Mike Mabey"
39+
author = u"Mike Mabey"
3740

3841
# The version info for the project you're documenting, acts as replacement for
3942
# |version| and |release|, also used in various other places throughout the
4043
# built documents.
4144
#
4245
# The full version, including alpha/beta/rc tags.
43-
release = open('../VERSION').read().strip()
46+
release = open("../VERSION").read().strip()
4447
# The short X.Y version.
45-
version = '.'.join(release.split('.')[:2])
48+
version = ".".join(release.split(".")[:2])
4649

4750
# The language for content autogenerated by Sphinx. Refer to documentation
4851
# for a list of supported languages.
@@ -54,7 +57,7 @@
5457
# List of patterns, relative to source directory, that match files and
5558
# directories to ignore when looking for source files.
5659
# This patterns also effect to html_static_path and html_extra_path
57-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
60+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
5861

5962
# The reST default role (used for this markup: `text`) to use for all
6063
# documents.
@@ -66,7 +69,7 @@
6669
add_function_parentheses = True
6770

6871
# The name of the Pygments (syntax highlighting) style to use.
69-
pygments_style = 'sphinx'
72+
pygments_style = "sphinx"
7073

7174
# If true, `todo` and `todoList` produce output, else they produce nothing.
7275
todo_include_todos = False
@@ -77,62 +80,70 @@
7780
# The theme to use for HTML and HTML Help pages. See the documentation for
7881
# a list of builtin themes.
7982
#
80-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
83+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
8184

8285
if not on_rtd: # only import and set the theme if we're building docs locally
8386
try:
8487
import sphinx_rtd_theme
85-
html_theme = 'sphinx_rtd_theme'
86-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
88+
89+
html_theme = "sphinx_rtd_theme"
90+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
8791
except:
88-
html_theme = 'default'
89-
html_theme_path = ['.']
92+
html_theme = "default"
93+
html_theme_path = ["."]
9094
else:
91-
html_theme_path = ['.']
95+
html_theme_path = ["."]
9296

9397
# Add any paths that contain custom static files (such as style sheets) here,
9498
# relative to this directory. They are copied after the builtin static files,
9599
# so a file named "default.css" will overwrite the builtin "default.css".
96-
html_static_path = ['_static']
100+
html_static_path = ["_static"]
97101

98102
# Output file base name for HTML help builder.
99-
htmlhelp_basename = 'AdafruitHCSR04Librarydoc'
103+
htmlhelp_basename = "AdafruitHCSR04Librarydoc"
100104

101105
# -- Options for LaTeX output ---------------------------------------------
102106

103107
latex_elements = {
104-
# The paper size ('letterpaper' or 'a4paper').
105-
#
106-
# 'papersize': 'letterpaper',
107-
108-
# The font size ('10pt', '11pt' or '12pt').
109-
#
110-
# 'pointsize': '10pt',
111-
112-
# Additional stuff for the LaTeX preamble.
113-
#
114-
# 'preamble': '',
115-
116-
# Latex figure (float) alignment
117-
#
118-
# 'figure_align': 'htbp',
108+
# The paper size ('letterpaper' or 'a4paper').
109+
#
110+
# 'papersize': 'letterpaper',
111+
# The font size ('10pt', '11pt' or '12pt').
112+
#
113+
# 'pointsize': '10pt',
114+
# Additional stuff for the LaTeX preamble.
115+
#
116+
# 'preamble': '',
117+
# Latex figure (float) alignment
118+
#
119+
# 'figure_align': 'htbp',
119120
}
120121

121122
# Grouping the document tree into LaTeX files. List of tuples
122123
# (source start file, target name, title,
123124
# author, documentclass [howto, manual, or own class]).
124125
latex_documents = [
125-
(master_doc, 'AdafruitHCSR04Library.tex', u'Adafruit HCSR04 Library Documentation',
126-
author, 'manual'),
126+
(
127+
master_doc,
128+
"AdafruitHCSR04Library.tex",
129+
u"Adafruit HCSR04 Library Documentation",
130+
author,
131+
"manual",
132+
),
127133
]
128134

129135
# -- Options for manual page output ---------------------------------------
130136

131137
# One entry per manual page. List of tuples
132138
# (source start file, name, description, authors, manual section).
133139
man_pages = [
134-
(master_doc, 'adafruitHCSR04library', u'Adafruit HCSR04 Library Documentation',
135-
[author], 1)
140+
(
141+
master_doc,
142+
"adafruitHCSR04library",
143+
u"Adafruit HCSR04 Library Documentation",
144+
[author],
145+
1,
146+
)
136147
]
137148

138149
# -- Options for Texinfo output -------------------------------------------
@@ -141,7 +152,13 @@
141152
# (source start file, target name, title, author,
142153
# dir menu entry, description, category)
143154
texinfo_documents = [
144-
(master_doc, 'AdafruitHCSR04Library', u'Adafruit HCSR04 Library Documentation',
145-
author, 'AdafruitHCSR04Library', 'One line description of project.',
146-
'Miscellaneous'),
155+
(
156+
master_doc,
157+
"AdafruitHCSR04Library",
158+
u"Adafruit HCSR04 Library Documentation",
159+
author,
160+
"AdafruitHCSR04Library",
161+
"One line description of project.",
162+
"Miscellaneous",
163+
),
147164
]

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-hcsr04',
22-
22+
name="adafruit-circuitpython-hcsr04",
2323
use_scm_version=True,
24-
setup_requires=['setuptools_scm'],
25-
26-
description='CircuitPython library for controlling HC-SR04 ultrasonic range sensors.',
24+
setup_requires=["setuptools_scm"],
25+
description="CircuitPython library for controlling HC-SR04 ultrasonic range sensors.",
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_HCSR04',
32-
29+
url="https://github.com/adafruit/Adafruit_CircuitPython_HCSR04",
3330
# Author details
34-
author='Adafruit Industries',
35-
author_email='circuitpython@adafruit.com',
36-
37-
install_requires=['Adafruit-Blinka'],
38-
31+
author="Adafruit Industries",
32+
author_email="circuitpython@adafruit.com",
33+
install_requires=["Adafruit-Blinka"],
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 hcsr04 hardware micropython circuitpython ultrasonic',
56-
48+
keywords="adafruit hcsr04 hardware micropython circuitpython ultrasonic",
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_hcsr04'],
60-
)
51+
py_modules=["adafruit_hcsr04"],
52+
)

0 commit comments

Comments
 (0)