Skip to content

Commit 0e376c2

Browse files
authored
Merge pull request #4 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents 1cbc2f3 + b4c6631 commit 0e376c2

File tree

6 files changed

+137
-115
lines changed

6 files changed

+137
-115
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_lps35hw.py

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -53,33 +53,35 @@
5353
from adafruit_register.i2c_struct import UnaryStruct
5454
from adafruit_register.i2c_bits import RWBits, ROBits
5555
from adafruit_register.i2c_bit import RWBit
56+
5657
# pylint: disable=bad-whitespace
57-
_INTERRUPT_CFG = const(0x0B)
58-
_THS_P_L = const(0x0C)
59-
_THS_P_H = const(0x0D)
60-
_WHO_AM_I = const(0x0F)
61-
_CTRL_REG1 = const(0x10)
62-
_CTRL_REG2 = const(0x11)
63-
_CTRL_REG3 = const(0x12)
64-
_FIFO_CTRL = const(0x14)
65-
_REF_P_XL = const(0x15)
66-
_REF_P_L = const(0x16)
67-
_REF_P_H = const(0x17)
68-
_RPDS_L = const(0x18)
69-
_RPDS_H = const(0x19)
70-
_RES_CONF = const(0x1A)
71-
_INT_SOURCE = const(0x25)
72-
_FIFO_STATUS = const(0x26)
73-
_STATUS = const(0x27)
74-
_PRESS_OUT_XL = const(0x28)
75-
_PRESS_OUT_L = const(0x29)
76-
_PRESS_OUT_H = const(0x2A)
77-
_TEMP_OUT_L = const(0x2B)
78-
_TEMP_OUT_H = const(0x2C)
79-
_LPFP_RES = const(0x33)
58+
_INTERRUPT_CFG = const(0x0B)
59+
_THS_P_L = const(0x0C)
60+
_THS_P_H = const(0x0D)
61+
_WHO_AM_I = const(0x0F)
62+
_CTRL_REG1 = const(0x10)
63+
_CTRL_REG2 = const(0x11)
64+
_CTRL_REG3 = const(0x12)
65+
_FIFO_CTRL = const(0x14)
66+
_REF_P_XL = const(0x15)
67+
_REF_P_L = const(0x16)
68+
_REF_P_H = const(0x17)
69+
_RPDS_L = const(0x18)
70+
_RPDS_H = const(0x19)
71+
_RES_CONF = const(0x1A)
72+
_INT_SOURCE = const(0x25)
73+
_FIFO_STATUS = const(0x26)
74+
_STATUS = const(0x27)
75+
_PRESS_OUT_XL = const(0x28)
76+
_PRESS_OUT_L = const(0x29)
77+
_PRESS_OUT_H = const(0x2A)
78+
_TEMP_OUT_L = const(0x2B)
79+
_TEMP_OUT_H = const(0x2C)
80+
_LPFP_RES = const(0x33)
8081
# pylint: enable=bad-whitespace
8182

82-
class DataRate: # pylint: disable=too-few-public-methods
83+
84+
class DataRate: # pylint: disable=too-few-public-methods
8385
"""Options for ``data_rate``
8486
8587
+---------------------------+-------------------------+
@@ -99,14 +101,16 @@ class DataRate: # pylint: disable=too-few-public-methods
99101
+---------------------------+-------------------------+
100102
101103
"""
104+
102105
ONE_SHOT = const(0x00)
103106
RATE_1_HZ = const(0x01)
104107
RATE_10_HZ = const(0x02)
105108
RATE_25_HZ = const(0x03)
106109
RATE_50_HZ = const(0x04)
107110
RATE_75_HZ = const(0x05)
108111

109-
class LPS35HW: # pylint: disable=too-many-instance-attributes
112+
113+
class LPS35HW: # pylint: disable=too-many-instance-attributes
110114
"""Driver for the ST LPS35HW MEMS pressure sensor
111115
112116
:param ~busio.I2C i2c_bus: The I2C bus the LPS34HW is connected to.
@@ -136,7 +140,7 @@ class LPS35HW: # pylint: disable=too-many-instance-attributes
136140
_one_shot = RWBit(_CTRL_REG2, 0)
137141

138142
# registers for configuring INT pin behavior
139-
_interrupt_cfg = UnaryStruct(_CTRL_REG3, "<B") # to read all values for latching?
143+
_interrupt_cfg = UnaryStruct(_CTRL_REG3, "<B") # to read all values for latching?
140144

141145
# INT status registers
142146
_interrupt_active = RWBit(_INT_SOURCE, 2)
@@ -156,10 +160,10 @@ class LPS35HW: # pylint: disable=too-many-instance-attributes
156160
_chip_id = UnaryStruct(_WHO_AM_I, "<B")
157161
_pressure_threshold = UnaryStruct(_THS_P_L, "<H")
158162

159-
def __init__(self, i2c_bus, address=0x5d):
163+
def __init__(self, i2c_bus, address=0x5D):
160164
self.i2c_device = i2cdevice.I2CDevice(i2c_bus, address)
161-
if self._chip_id != 0xb1:
162-
raise RuntimeError('Failed to find LPS35HW! Chip ID 0x%x' % self._chip_id)
165+
if self._chip_id != 0xB1:
166+
raise RuntimeError("Failed to find LPS35HW! Chip ID 0x%x" % self._chip_id)
163167

164168
self.reset()
165169

@@ -173,12 +177,12 @@ def __init__(self, i2c_bus, address=0x5d):
173177
def pressure(self):
174178
"""The current pressure measurement in hPa"""
175179
# reset the filter to prevent spurious readings
176-
self._reset_filter # pylint: disable=pointless-statement
180+
self._reset_filter # pylint: disable=pointless-statement
177181

178182
# check for negative and convert
179183
raw = self._raw_pressure
180-
if raw & (1<<23) != 0:
181-
raw = (raw - (1<<24))
184+
if raw & (1 << 23) != 0:
185+
raw = raw - (1 << 24)
182186
return raw / 4096.0
183187

184188
@property
@@ -219,7 +223,7 @@ def pressure_threshold(self):
219223
@pressure_threshold.setter
220224
def pressure_threshold(self, value):
221225
"""The high value threshold"""
222-
self._pressure_threshold = (value * 16)
226+
self._pressure_threshold = value * 16
223227

224228
@property
225229
def high_threshold_enabled(self):

docs/conf.py

Lines changed: 73 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,40 @@
2324
autodoc_mock_imports = ["micropython", "adafruit_bus_device", "adafruit_register"]
2425

2526

26-
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None),'Register': ('https://circuitpython.readthedocs.io/projects/register/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+
"Register": (
34+
"https://circuitpython.readthedocs.io/projects/register/en/latest/",
35+
None,
36+
),
37+
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
38+
}
2739

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

31-
source_suffix = '.rst'
43+
source_suffix = ".rst"
3244

3345
# The master toctree document.
34-
master_doc = 'index'
46+
master_doc = "index"
3547

3648
# General information about the project.
37-
project = u'Adafruit LPS35HW Library'
38-
copyright = u'2019 Bryan Siepert'
39-
author = u'Bryan Siepert'
49+
project = u"Adafruit LPS35HW Library"
50+
copyright = u"2019 Bryan Siepert"
51+
author = u"Bryan Siepert"
4052

4153
# The version info for the project you're documenting, acts as replacement for
4254
# |version| and |release|, also used in various other places throughout the
4355
# built documents.
4456
#
4557
# The short X.Y version.
46-
version = u'1.0'
58+
version = u"1.0"
4759
# The full version, including alpha/beta/rc tags.
48-
release = u'1.0'
60+
release = u"1.0"
4961

5062
# The language for content autogenerated by Sphinx. Refer to documentation
5163
# for a list of supported languages.
@@ -57,7 +69,7 @@
5769
# List of patterns, relative to source directory, that match files and
5870
# directories to ignore when looking for source files.
5971
# 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']
72+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
6173

6274
# The reST default role (used for this markup: `text`) to use for all
6375
# documents.
@@ -69,7 +81,7 @@
6981
add_function_parentheses = True
7082

7183
# The name of the Pygments (syntax highlighting) style to use.
72-
pygments_style = 'sphinx'
84+
pygments_style = "sphinx"
7385

7486
# If true, `todo` and `todoList` produce output, else they produce nothing.
7587
todo_include_todos = False
@@ -84,68 +96,76 @@
8496
# The theme to use for HTML and HTML Help pages. See the documentation for
8597
# a list of builtin themes.
8698
#
87-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
99+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
88100

89101
if not on_rtd: # only import and set the theme if we're building docs locally
90102
try:
91103
import sphinx_rtd_theme
92-
html_theme = 'sphinx_rtd_theme'
93-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
104+
105+
html_theme = "sphinx_rtd_theme"
106+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
94107
except:
95-
html_theme = 'default'
96-
html_theme_path = ['.']
108+
html_theme = "default"
109+
html_theme_path = ["."]
97110
else:
98-
html_theme_path = ['.']
111+
html_theme_path = ["."]
99112

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

105118
# The name of an image file (relative to this directory) to use as a favicon of
106119
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
107120
# pixels large.
108121
#
109-
html_favicon = '_static/favicon.ico'
122+
html_favicon = "_static/favicon.ico"
110123

111124
# Output file base name for HTML help builder.
112-
htmlhelp_basename = 'AdafruitLps35hwLibrarydoc'
125+
htmlhelp_basename = "AdafruitLps35hwLibrarydoc"
113126

114127
# -- Options for LaTeX output ---------------------------------------------
115128

116129
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',
130+
# The paper size ('letterpaper' or 'a4paper').
131+
#
132+
# 'papersize': 'letterpaper',
133+
# The font size ('10pt', '11pt' or '12pt').
134+
#
135+
# 'pointsize': '10pt',
136+
# Additional stuff for the LaTeX preamble.
137+
#
138+
# 'preamble': '',
139+
# Latex figure (float) alignment
140+
#
141+
# 'figure_align': 'htbp',
132142
}
133143

134144
# Grouping the document tree into LaTeX files. List of tuples
135145
# (source start file, target name, title,
136146
# author, documentclass [howto, manual, or own class]).
137147
latex_documents = [
138-
(master_doc, 'AdafruitLPS35HWLibrary.tex', u'AdafruitLPS35HW Library Documentation',
139-
author, 'manual'),
148+
(
149+
master_doc,
150+
"AdafruitLPS35HWLibrary.tex",
151+
u"AdafruitLPS35HW Library Documentation",
152+
author,
153+
"manual",
154+
),
140155
]
141156

142157
# -- Options for manual page output ---------------------------------------
143158

144159
# One entry per manual page. List of tuples
145160
# (source start file, name, description, authors, manual section).
146161
man_pages = [
147-
(master_doc, 'AdafruitLPS35HWlibrary', u'Adafruit LPS35HW Library Documentation',
148-
[author], 1)
162+
(
163+
master_doc,
164+
"AdafruitLPS35HWlibrary",
165+
u"Adafruit LPS35HW Library Documentation",
166+
[author],
167+
1,
168+
)
149169
]
150170

151171
# -- Options for Texinfo output -------------------------------------------
@@ -154,7 +174,13 @@
154174
# (source start file, target name, title, author,
155175
# dir menu entry, description, category)
156176
texinfo_documents = [
157-
(master_doc, 'AdafruitLPS35HWLibrary', u'Adafruit LPS35HW Library Documentation',
158-
author, 'AdafruitLPS35HWLibrary', 'One line description of project.',
159-
'Miscellaneous'),
177+
(
178+
master_doc,
179+
"AdafruitLPS35HWLibrary",
180+
u"Adafruit LPS35HW Library Documentation",
181+
author,
182+
"AdafruitLPS35HWLibrary",
183+
"One line description of project.",
184+
"Miscellaneous",
185+
),
160186
]

examples/lps35hw_data_rate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
print("")
2121
time.sleep(1)
2222

23-
#take another measurement
23+
# take another measurement
2424
lps.take_measurement()
2525

2626
print("New Pressure: %.2f hPa" % lps.pressure)

examples/lps35hw_simpletest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77

88
while True:
99
print("Pressure: %.2f hPa" % lps.pressure)
10-
print("Temperature: %.2f C"% lps.temperature)
10+
print("Temperature: %.2f C" % lps.temperature)
1111
print("")
1212
time.sleep(1)

0 commit comments

Comments
 (0)