Skip to content

Commit d4a0f11

Browse files
authored
Merge pull request #10 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents 3e90044 + 2eb6911 commit d4a0f11

File tree

5 files changed

+117
-94
lines changed

5 files changed

+117
-94
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

adafruit_lidarlite.py

+22-13
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,15 @@
7474
STATUS_SYS_ERROR = 0x40
7575

7676
# The various configuration register values, from arduino library
77-
_LIDAR_CONFIGS = ((0x80, 0x08, 0x00), # default
78-
(0x1D, 0x08, 0x00), # short range, high speed
79-
(0x80, 0x00, 0x00), # default range, higher speed short range
80-
(0xFF, 0x08, 0x00), # maximum range
81-
(0x80, 0x08, 0x80), # high sensitivity & error
82-
(0x80, 0x08, 0xb0)) # low sensitivity & error
77+
_LIDAR_CONFIGS = (
78+
(0x80, 0x08, 0x00), # default
79+
(0x1D, 0x08, 0x00), # short range, high speed
80+
(0x80, 0x00, 0x00), # default range, higher speed short range
81+
(0xFF, 0x08, 0x00), # maximum range
82+
(0x80, 0x08, 0x80), # high sensitivity & error
83+
(0x80, 0x08, 0xB0),
84+
) # low sensitivity & error
85+
8386

8487
class LIDARLite:
8588
"""
@@ -89,8 +92,14 @@ class LIDARLite:
8992
:param int address: (optional) The I2C address of the device to set after initialization.
9093
"""
9194

92-
def __init__(self, i2c_bus, *, reset_pin=None,
93-
configuration=CONFIG_DEFAULT, address=_ADDR_DEFAULT):
95+
def __init__(
96+
self,
97+
i2c_bus,
98+
*,
99+
reset_pin=None,
100+
configuration=CONFIG_DEFAULT,
101+
address=_ADDR_DEFAULT
102+
):
94103
"""Initialize the hardware for the LIDAR over I2C. You can pass in an
95104
optional reset_pin for when you call reset(). There are a few common
96105
configurations Garmin suggests: CONFIG_DEFAULT, CONFIG_SHORTFAST,
@@ -121,7 +130,7 @@ def reset(self):
121130
try:
122131
self._write_reg(_REG_ACQ_COMMAND, _CMD_RESET)
123132
except OSError:
124-
pass # it doesnt respond well once reset
133+
pass # it doesnt respond well once reset
125134
time.sleep(1)
126135
# take 100 readings to 'flush' out sensor!
127136
for _ in range(100):
@@ -138,7 +147,7 @@ def configure(self, config):
138147
settings = _LIDAR_CONFIGS[config]
139148
self._write_reg(0x02, settings[0])
140149
self._write_reg(0x04, settings[1])
141-
self._write_reg(0x1c, settings[2])
150+
self._write_reg(0x1C, settings[2])
142151

143152
def read_distance(self, bias=False):
144153
"""Perform a distance reading with or without 'bias'. It's recommended
@@ -159,7 +168,7 @@ def distance(self):
159168
"""The measured distance in cm. Will take a bias reading every 100 calls"""
160169
self._bias_count -= 1
161170
if self._bias_count < 0:
162-
self._bias_count = 100 # every 100 reads, check bias
171+
self._bias_count = 100 # every 100 reads, check bias
163172
return self.read_distance(self._bias_count <= 0)
164173

165174
@property
@@ -174,7 +183,7 @@ def _write_reg(self, reg, value):
174183
self._buf[0] = reg
175184
self._buf[1] = value
176185
with self.i2c_device as i2c:
177-
#print("Writing: ", [hex(i) for i in self._buf])
186+
# print("Writing: ", [hex(i) for i in self._buf])
178187
i2c.write(self._buf)
179188
time.sleep(0.001) # there's a delay in arduino library
180189

@@ -187,5 +196,5 @@ def _read_reg(self, reg, num):
187196
self._buf[0] = reg
188197
with self.i2c_device as i2c:
189198
i2c.write_then_readinto(self._buf, self._buf, out_end=1, in_end=num)
190-
#print("Read from ", hex(reg), [hex(i) for i in self._buf])
199+
# print("Read from ", hex(reg), [hex(i) for i in self._buf])
191200
return self._buf

docs/conf.py

+69-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,36 @@
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),'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+
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
34+
}
2735

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

31-
source_suffix = '.rst'
39+
source_suffix = ".rst"
3240

3341
# The master toctree document.
34-
master_doc = 'index'
42+
master_doc = "index"
3543

3644
# General information about the project.
37-
project = u'Adafruit LIDARLite Library'
38-
copyright = u'2018 ladyada'
39-
author = u'ladyada'
45+
project = u"Adafruit LIDARLite Library"
46+
copyright = u"2018 ladyada"
47+
author = u"ladyada"
4048

4149
# The version info for the project you're documenting, acts as replacement for
4250
# |version| and |release|, also used in various other places throughout the
4351
# built documents.
4452
#
4553
# The short X.Y version.
46-
version = u'1.0'
54+
version = u"1.0"
4755
# The full version, including alpha/beta/rc tags.
48-
release = u'1.0'
56+
release = u"1.0"
4957

5058
# The language for content autogenerated by Sphinx. Refer to documentation
5159
# for a list of supported languages.
@@ -57,7 +65,7 @@
5765
# List of patterns, relative to source directory, that match files and
5866
# directories to ignore when looking for source files.
5967
# 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']
68+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
6169

6270
# The reST default role (used for this markup: `text`) to use for all
6371
# documents.
@@ -69,7 +77,7 @@
6977
add_function_parentheses = True
7078

7179
# The name of the Pygments (syntax highlighting) style to use.
72-
pygments_style = 'sphinx'
80+
pygments_style = "sphinx"
7381

7482
# If true, `todo` and `todoList` produce output, else they produce nothing.
7583
todo_include_todos = False
@@ -84,68 +92,76 @@
8492
# The theme to use for HTML and HTML Help pages. See the documentation for
8593
# a list of builtin themes.
8694
#
87-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
95+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
8896

8997
if not on_rtd: # only import and set the theme if we're building docs locally
9098
try:
9199
import sphinx_rtd_theme
92-
html_theme = 'sphinx_rtd_theme'
93-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
100+
101+
html_theme = "sphinx_rtd_theme"
102+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
94103
except:
95-
html_theme = 'default'
96-
html_theme_path = ['.']
104+
html_theme = "default"
105+
html_theme_path = ["."]
97106
else:
98-
html_theme_path = ['.']
107+
html_theme_path = ["."]
99108

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

105114
# The name of an image file (relative to this directory) to use as a favicon of
106115
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
107116
# pixels large.
108117
#
109-
html_favicon = '_static/favicon.ico'
118+
html_favicon = "_static/favicon.ico"
110119

111120
# Output file base name for HTML help builder.
112-
htmlhelp_basename = 'AdafruitLidarliteLibrarydoc'
121+
htmlhelp_basename = "AdafruitLidarliteLibrarydoc"
113122

114123
# -- Options for LaTeX output ---------------------------------------------
115124

116125
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',
126+
# The paper size ('letterpaper' or 'a4paper').
127+
#
128+
# 'papersize': 'letterpaper',
129+
# The font size ('10pt', '11pt' or '12pt').
130+
#
131+
# 'pointsize': '10pt',
132+
# Additional stuff for the LaTeX preamble.
133+
#
134+
# 'preamble': '',
135+
# Latex figure (float) alignment
136+
#
137+
# 'figure_align': 'htbp',
132138
}
133139

134140
# Grouping the document tree into LaTeX files. List of tuples
135141
# (source start file, target name, title,
136142
# author, documentclass [howto, manual, or own class]).
137143
latex_documents = [
138-
(master_doc, 'AdafruitLIDARLiteLibrary.tex', u'AdafruitLIDARLite Library Documentation',
139-
author, 'manual'),
144+
(
145+
master_doc,
146+
"AdafruitLIDARLiteLibrary.tex",
147+
u"AdafruitLIDARLite Library Documentation",
148+
author,
149+
"manual",
150+
),
140151
]
141152

142153
# -- Options for manual page output ---------------------------------------
143154

144155
# One entry per manual page. List of tuples
145156
# (source start file, name, description, authors, manual section).
146157
man_pages = [
147-
(master_doc, 'AdafruitLIDARLitelibrary', u'Adafruit LIDARLite Library Documentation',
148-
[author], 1)
158+
(
159+
master_doc,
160+
"AdafruitLIDARLitelibrary",
161+
u"Adafruit LIDARLite Library Documentation",
162+
[author],
163+
1,
164+
)
149165
]
150166

151167
# -- Options for Texinfo output -------------------------------------------
@@ -154,7 +170,13 @@
154170
# (source start file, target name, title, author,
155171
# dir menu entry, description, category)
156172
texinfo_documents = [
157-
(master_doc, 'AdafruitLIDARLiteLibrary', u'Adafruit LIDARLite Library Documentation',
158-
author, 'AdafruitLIDARLiteLibrary', 'One line description of project.',
159-
'Miscellaneous'),
173+
(
174+
master_doc,
175+
"AdafruitLIDARLiteLibrary",
176+
u"Adafruit LIDARLite Library Documentation",
177+
author,
178+
"AdafruitLIDARLiteLibrary",
179+
"One line description of project.",
180+
"Miscellaneous",
181+
),
160182
]

examples/lidarlite_simpletest.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
sensor = adafruit_lidarlite.LIDARLite(i2c)
1212

1313
# Optionally, we can pass in a hardware reset pin, or custom config
14-
#import digitalio
15-
#reset = digitalio.DigitalInOut(board.D5)
16-
#sensor = adafruit_lidarlite.LIDARLite(i2c, reset_pin=reset,
14+
# import digitalio
15+
# reset = digitalio.DigitalInOut(board.D5)
16+
# sensor = adafruit_lidarlite.LIDARLite(i2c, reset_pin=reset,
1717
# configuration=adafruit_lidarlite.CONFIG_MAXRANGE)
1818

1919
# If you want to reset, you can do so, note that it can take 10-20 seconds
@@ -27,4 +27,4 @@
2727
except RuntimeError as e:
2828
# If we get a reading error, just print it and keep truckin'
2929
print(e)
30-
time.sleep(0.01) # you can remove this for ultra-fast measurements!
30+
time.sleep(0.01) # you can remove this for ultra-fast measurements!

setup.py

+21-29
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-lidarlite',
22-
22+
name="adafruit-circuitpython-lidarlite",
2323
use_scm_version=True,
24-
setup_requires=['setuptools_scm'],
25-
26-
description='A CircuitPython & Python library for Garmin LIDAR Lite sensors over I2C.',
24+
setup_requires=["setuptools_scm"],
25+
description="A CircuitPython & Python library for Garmin LIDAR Lite sensors over I2C.",
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_LIDARLite',
32-
29+
url="https://github.com/adafruit/Adafruit_CircuitPython_LIDARLite",
3330
# Author details
34-
author='Adafruit Industries',
35-
author_email='[email protected]',
36-
37-
install_requires=['Adafruit-Blinka', 'adafruit-circuitpython-busdevice'],
38-
31+
author="Adafruit Industries",
32+
author_email="[email protected]",
33+
install_requires=["Adafruit-Blinka", "adafruit-circuitpython-busdevice"],
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 lidarlite lidar garmin i2c hardware sensor micropython circuitpython',
56-
48+
keywords="adafruit lidarlite lidar garmin i2c hardware sensor 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_lidarlite'],
51+
py_modules=["adafruit_lidarlite"],
6052
)

0 commit comments

Comments
 (0)