Skip to content

Commit 5b86bae

Browse files
committed
Ran black, updated to pylint 2.x
1 parent d1376b1 commit 5b86bae

File tree

6 files changed

+141
-110
lines changed

6 files changed

+141
-110
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

.pylintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ spelling-store-unknown-words=no
119119
[MISCELLANEOUS]
120120

121121
# List of note tags to take in consideration, separated by a comma.
122-
notes=FIXME,XXX,TODO
122+
# notes=FIXME,XXX,TODO
123+
notes=FIXME,XXX
123124

124125

125126
[TYPECHECK]

adafruit_ccs811.py

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,15 @@
7373
_HW_ID_CODE = const(0x81)
7474
_REF_RESISTOR = const(100000)
7575

76+
7677
class CCS811:
7778
"""CCS811 gas sensor driver.
7879
7980
:param ~busio.I2C i2c: The I2C bus.
8081
:param int addr: The I2C address of the CCS811.
8182
"""
82-
#set up the registers
83+
84+
# set up the registers
8385
error = i2c_bit.ROBit(0x00, 0)
8486
"""True when an error has occured."""
8587
data_ready = i2c_bit.ROBit(0x00, 3)
@@ -99,32 +101,38 @@ class CCS811:
99101
def __init__(self, i2c_bus, address=0x5A):
100102
self.i2c_device = I2CDevice(i2c_bus, address)
101103

102-
#check that the HW id is correct
104+
# check that the HW id is correct
103105
if self.hw_id != _HW_ID_CODE:
104-
raise RuntimeError("Device ID returned is not correct! Please check your wiring.")
106+
raise RuntimeError(
107+
"Device ID returned is not correct! Please check your wiring."
108+
)
105109

106-
#try to start the app
110+
# try to start the app
107111
buf = bytearray(1)
108112
buf[0] = 0xF4
109113
with self.i2c_device as i2c:
110114
i2c.write(buf, end=1)
111-
time.sleep(.1)
115+
time.sleep(0.1)
112116

113-
#make sure there are no errors and we have entered application mode
117+
# make sure there are no errors and we have entered application mode
114118
if self.error:
115-
raise RuntimeError("Device returned a error! Try removing and reapplying power to "
116-
"the device and running the code again.")
119+
raise RuntimeError(
120+
"Device returned a error! Try removing and reapplying power to "
121+
"the device and running the code again."
122+
)
117123
if not self.fw_mode:
118-
raise RuntimeError("Device did not enter application mode! If you got here, there may "
119-
"be a problem with the firmware on your sensor.")
124+
raise RuntimeError(
125+
"Device did not enter application mode! If you got here, there may "
126+
"be a problem with the firmware on your sensor."
127+
)
120128

121129
self.interrupt_enabled = False
122130

123-
#default to read every second
131+
# default to read every second
124132
self.drive_mode = DRIVE_MODE_1SEC
125133

126-
self._eco2 = None # pylint: disable=invalid-name
127-
self._tvoc = None # pylint: disable=invalid-name
134+
self._eco2 = None # pylint: disable=invalid-name
135+
self._tvoc = None # pylint: disable=invalid-name
128136

129137
@property
130138
def error_code(self):
@@ -149,13 +157,13 @@ def _update_data(self):
149157
raise RuntimeError("Error:" + str(self.error_code))
150158

151159
@property
152-
def tvoc(self): # pylint: disable=invalid-name
160+
def tvoc(self): # pylint: disable=invalid-name
153161
"""Total Volatile Organic Compound in parts per billion."""
154162
self._update_data()
155163
return self._tvoc
156164

157165
@property
158-
def eco2(self): # pylint: disable=invalid-name
166+
def eco2(self): # pylint: disable=invalid-name
159167
"""Equivalent Carbon Dioxide in parts per million. Clipped to 400 to 8192ppm."""
160168
self._update_data()
161169
return self._eco2
@@ -216,18 +224,22 @@ def set_interrupt_thresholds(self, low_med, med_high, hysteresis):
216224
:param int low_med: Boundary between low and medium ranges
217225
:param int med_high: Boundary between medium and high ranges
218226
:param int hysteresis: Minimum difference between reads"""
219-
buf = bytearray([_THRESHOLDS,
220-
((low_med >> 8) & 0xF),
221-
(low_med & 0xF),
222-
((med_high >> 8) & 0xF),
223-
(med_high & 0xF),
224-
hysteresis])
227+
buf = bytearray(
228+
[
229+
_THRESHOLDS,
230+
((low_med >> 8) & 0xF),
231+
(low_med & 0xF),
232+
((med_high >> 8) & 0xF),
233+
(med_high & 0xF),
234+
hysteresis,
235+
]
236+
)
225237
with self.i2c_device as i2c:
226238
i2c.write(buf)
227239

228240
def reset(self):
229241
"""Initiate a software reset."""
230-
#reset sequence from the datasheet
242+
# reset sequence from the datasheet
231243
seq = bytearray([_SW_RESET, 0x11, 0xE5, 0x72, 0x8A])
232244
with self.i2c_device as i2c:
233245
i2c.write(seq)

docs/conf.py

Lines changed: 77 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
#
1919
import os
2020
import sys
21-
sys.path.insert(0, os.path.abspath('..'))
21+
22+
sys.path.insert(0, os.path.abspath(".."))
2223

2324
# -- General configuration ------------------------------------------------
2425

@@ -30,54 +31,61 @@
3031
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3132
# ones.
3233
extensions = [
33-
'sphinx.ext.autodoc',
34-
'sphinx.ext.todo',
35-
'sphinx.ext.viewcode',
36-
'sphinx.ext.intersphinx'
34+
"sphinx.ext.autodoc",
35+
"sphinx.ext.todo",
36+
"sphinx.ext.viewcode",
37+
"sphinx.ext.intersphinx",
3738
]
3839

3940
# Uncomment the below if you use native CircuitPython modules such as
4041
# digitalio, micropython and busio. List the modules you use. Without it, the
4142
# autodoc module docs will fail to generate with a warning.
4243
# autodoc_mock_imports = ["micropython", "adafruit_bus_device", "adafruit_register"]
4344

44-
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)}
45+
intersphinx_mapping = {
46+
"python": ("https://docs.python.org/3.4", None),
47+
"BusDevice": (
48+
"https://circuitpython.readthedocs.io/projects/busdevice/en/latest/",
49+
None,
50+
),
51+
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
52+
}
4553

4654
# Mock out micropython ourselves.
47-
#import imp
48-
#m = imp.new_module("micropython")
49-
#m.const = lambda x: x
50-
#sys.modules["micropython"] = m
55+
# import imp
56+
# m = imp.new_module("micropython")
57+
# m.const = lambda x: x
58+
# sys.modules["micropython"] = m
5159

5260
# Add any paths that contain templates here, relative to this directory.
53-
templates_path = ['_templates']
61+
templates_path = ["_templates"]
5462

5563
# The suffix(es) of source filenames.
5664
# You can specify multiple suffix as a list of string:
5765
#
58-
#source_suffix = ['.rst', '.md']
59-
source_suffix = '.rst'
66+
# source_suffix = ['.rst', '.md']
67+
source_suffix = ".rst"
6068

6169
# The encoding of source files.
6270
#
6371
# source_encoding = 'utf-8-sig'
6472

6573
# The master toctree document.
66-
master_doc = 'index'
74+
master_doc = "index"
6775

6876
# General information about the project.
69-
project = u'Adafruit\'s CCS811 Library'
70-
copyright = u'2016, Dean Miller, Scott Shawcroft'
71-
author = u'Dean Miller, Scott Shawcroft'
77+
project = u"Adafruit's CCS811 Library"
78+
copyright = u"2016, Dean Miller, Scott Shawcroft"
79+
author = u"Dean Miller, Scott Shawcroft"
7280

7381
# The version info for the project you're documenting, acts as replacement for
7482
# |version| and |release|, also used in various other places throughout the
7583
# built documents.
7684
#
7785
# The short X.Y version.
78-
version = u'1.0'
86+
version = u"1.0"
7987
# The full version, including alpha/beta/rc tags.
80-
release = u'1.0'
88+
release = u"1.0"
8189

8290
# The language for content autogenerated by Sphinx. Refer to documentation
8391
# for a list of supported languages.
@@ -98,7 +106,7 @@
98106
# List of patterns, relative to source directory, that match files and
99107
# directories to ignore when looking for source files.
100108
# This patterns also effect to html_static_path and html_extra_path
101-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
109+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
102110

103111
# The reST default role (used for this markup: `text`) to use for all
104112
# documents.
@@ -120,7 +128,7 @@
120128
# show_authors = False
121129

122130
# The name of the Pygments (syntax highlighting) style to use.
123-
pygments_style = 'sphinx'
131+
pygments_style = "sphinx"
124132

125133
# A list of ignored prefixes for module index sorting.
126134
# modindex_common_prefix = []
@@ -140,18 +148,19 @@
140148
# The theme to use for HTML and HTML Help pages. See the documentation for
141149
# a list of builtin themes.
142150
#
143-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
151+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
144152

145153
if not on_rtd: # only import and set the theme if we're building docs locally
146154
try:
147155
import sphinx_rtd_theme
148-
html_theme = 'sphinx_rtd_theme'
149-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
156+
157+
html_theme = "sphinx_rtd_theme"
158+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
150159
except:
151-
html_theme = 'default'
152-
html_theme_path = ['.']
160+
html_theme = "default"
161+
html_theme_path = ["."]
153162
else:
154-
html_theme_path = ['.']
163+
html_theme_path = ["."]
155164

156165
# Theme options are theme-specific and customize the look and feel of a theme
157166
# further. For a list of options available for each theme, see the
@@ -185,13 +194,13 @@
185194
# Add any paths that contain custom static files (such as style sheets) here,
186195
# relative to this directory. They are copied after the builtin static files,
187196
# so a file named "default.css" will overwrite the builtin "default.css".
188-
html_static_path = ['_static']
197+
html_static_path = ["_static"]
189198

190199
# The name of an image file (relative to this directory) to use as a favicon of
191200
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
192201
# pixels large.
193202
#
194-
html_favicon = '_static/favicon.ico'
203+
html_favicon = "_static/favicon.ico"
195204

196205
# Add any extra paths that contain custom files (such as robots.txt or
197206
# .htaccess) here, relative to this directory. These files are copied
@@ -276,29 +285,31 @@
276285
# -- Options for LaTeX output ---------------------------------------------
277286

278287
latex_elements = {
279-
# The paper size ('letterpaper' or 'a4paper').
280-
#
281-
# 'papersize': 'letterpaper',
282-
283-
# The font size ('10pt', '11pt' or '12pt').
284-
#
285-
# 'pointsize': '10pt',
286-
287-
# Additional stuff for the LaTeX preamble.
288-
#
289-
# 'preamble': '',
290-
291-
# Latex figure (float) alignment
292-
#
293-
# 'figure_align': 'htbp',
288+
# The paper size ('letterpaper' or 'a4paper').
289+
#
290+
# 'papersize': 'letterpaper',
291+
# The font size ('10pt', '11pt' or '12pt').
292+
#
293+
# 'pointsize': '10pt',
294+
# Additional stuff for the LaTeX preamble.
295+
#
296+
# 'preamble': '',
297+
# Latex figure (float) alignment
298+
#
299+
# 'figure_align': 'htbp',
294300
}
295301

296302
# Grouping the document tree into LaTeX files. List of tuples
297303
# (source start file, target name, title,
298304
# author, documentclass [howto, manual, or own class]).
299305
latex_documents = [
300-
(master_doc, 'AdafruitsCCS811Library.tex', u'Adafruit\'s CCS811 Library Documentation',
301-
u'Dean Miller, Scott Shawcroft', 'manual'),
306+
(
307+
master_doc,
308+
"AdafruitsCCS811Library.tex",
309+
u"Adafruit's CCS811 Library Documentation",
310+
u"Dean Miller, Scott Shawcroft",
311+
"manual",
312+
),
302313
]
303314

304315
# The name of an image file (relative to this directory) to place at the top of
@@ -339,8 +350,13 @@
339350
# One entry per manual page. List of tuples
340351
# (source start file, name, description, authors, manual section).
341352
man_pages = [
342-
(master_doc, 'AdafruitsCCS811Library23library', u'Adafruit\'s CCS811 Library Documentation',
343-
[author], 1)
353+
(
354+
master_doc,
355+
"AdafruitsCCS811Library23library",
356+
u"Adafruit's CCS811 Library Documentation",
357+
[author],
358+
1,
359+
)
344360
]
345361

346362
# If true, show URL addresses after external links.
@@ -354,9 +370,15 @@
354370
# (source start file, target name, title, author,
355371
# dir menu entry, description, category)
356372
texinfo_documents = [
357-
(master_doc, 'AdafruitsCCS811Library', u'Adafruit\'s CCS811 Library Documentation',
358-
author, 'AdafruitsCCS811Library', 'One line description of project.',
359-
'Miscellaneous'),
373+
(
374+
master_doc,
375+
"AdafruitsCCS811Library",
376+
u"Adafruit's CCS811 Library Documentation",
377+
author,
378+
"AdafruitsCCS811Library",
379+
"One line description of project.",
380+
"Miscellaneous",
381+
),
360382
]
361383

362384
# Documents to append as an appendix to all manuals.
@@ -375,5 +397,7 @@
375397
#
376398
# texinfo_no_detailmenu = False
377399

378-
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),
379-
'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
400+
intersphinx_mapping = {
401+
"python": ("https://docs.python.org/3.4", None),
402+
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
403+
}

examples/ccs811_simpletest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@
1111
pass
1212

1313
while True:
14-
print("CO2: {} PPM, TVOC: {} PPB"
15-
.format(ccs811.eco2, ccs811.tvoc))
14+
print("CO2: {} PPM, TVOC: {} PPB".format(ccs811.eco2, ccs811.tvoc))
1615
time.sleep(0.5)

0 commit comments

Comments
 (0)