Skip to content

Commit 6e785e6

Browse files
authored
Merge pull request #15 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents ed691e3 + a7cd483 commit 6e785e6

File tree

5 files changed

+151
-112
lines changed

5 files changed

+151
-112
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_veml6070.py

Lines changed: 58 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -55,28 +55,31 @@
5555

5656
# Set I2C addresses:
5757
# pylint: disable=bad-whitespace
58-
_VEML6070_ADDR_ARA = const(0x18 >> 1)
59-
_VEML6070_ADDR_CMD = const(0x70 >> 1)
60-
_VEML6070_ADDR_LOW = const(0x71 >> 1)
58+
_VEML6070_ADDR_ARA = const(0x18 >> 1)
59+
_VEML6070_ADDR_CMD = const(0x70 >> 1)
60+
_VEML6070_ADDR_LOW = const(0x71 >> 1)
6161
_VEML6070_ADDR_HIGH = const(0x73 >> 1)
6262

6363
# Integration Time dictionary. [0] is the byte setting; [1] is the risk
6464
# level divisor.
65-
_VEML6070_INTEGRATION_TIME = { "VEML6070_HALF_T": [0x00, 0],
66-
"VEML6070_1_T": [0x01, 1],
67-
"VEML6070_2_T": [0x02, 2],
68-
"VEML6070_4_T": [0x03, 4]
69-
}
65+
_VEML6070_INTEGRATION_TIME = {
66+
"VEML6070_HALF_T": [0x00, 0],
67+
"VEML6070_1_T": [0x01, 1],
68+
"VEML6070_2_T": [0x02, 2],
69+
"VEML6070_4_T": [0x03, 4],
70+
}
7071

7172
# UV Risk Level dictionary. [0],[1] are the lower and uppper bounds of the range
72-
_VEML6070_RISK_LEVEL = { "LOW": [0, 560],
73-
"MODERATE": [561, 1120],
74-
"HIGH": [1121, 1494],
75-
"VERY HIGH": [1495, 2054],
76-
"EXTREME": [2055, 9999]
77-
}
73+
_VEML6070_RISK_LEVEL = {
74+
"LOW": [0, 560],
75+
"MODERATE": [561, 1120],
76+
"HIGH": [1121, 1494],
77+
"VERY HIGH": [1495, 2054],
78+
"EXTREME": [2055, 9999],
79+
}
7880
# pylint: enable=bad-whitespace
7981

82+
8083
class VEML6070:
8184
"""
8285
Driver base for the VEML6070 UV Light Sensor
@@ -114,8 +117,10 @@ class VEML6070:
114117
def __init__(self, i2c_bus, _veml6070_it="VEML6070_1_T", ack=False):
115118
# Check if the IT is valid
116119
if _veml6070_it not in _VEML6070_INTEGRATION_TIME:
117-
raise ValueError('Integration Time invalid. Valid values are: ',
118-
_VEML6070_INTEGRATION_TIME.keys())
120+
raise ValueError(
121+
"Integration Time invalid. Valid values are: ",
122+
_VEML6070_INTEGRATION_TIME.keys(),
123+
)
119124

120125
# Check if ACK is valid
121126
if ack not in (True, False):
@@ -136,14 +141,15 @@ def __init__(self, i2c_bus, _veml6070_it="VEML6070_1_T", ack=False):
136141
try:
137142
with I2CDevice(i2c_bus, _VEML6070_ADDR_ARA) as ara:
138143
ara.readinto(ara_buf)
139-
except ValueError: # the ARA address is never valid? datasheet error?
144+
except ValueError: # the ARA address is never valid? datasheet error?
140145
pass
141146
self.buf = bytearray(1)
142-
self.buf[0] = self._ack << 5 | _VEML6070_INTEGRATION_TIME[self._it][0] << 2 | 0x02
147+
self.buf[0] = (
148+
self._ack << 5 | _VEML6070_INTEGRATION_TIME[self._it][0] << 2 | 0x02
149+
)
143150
with self.i2c_cmd as i2c_cmd:
144151
i2c_cmd.write(self.buf)
145152

146-
147153
@property
148154
def uv_raw(self):
149155
"""
@@ -172,8 +178,12 @@ def ack(self, new_ack):
172178
if new_ack != bool(new_ack):
173179
raise ValueError("ACK must be 'True' or 'False'.")
174180
self._ack = int(new_ack)
175-
self.buf[0] = (self._ack << 5 | self._ack_thd << 4 |
176-
_VEML6070_INTEGRATION_TIME[self._it][0] << 2 | 0x02)
181+
self.buf[0] = (
182+
self._ack << 5
183+
| self._ack_thd << 4
184+
| _VEML6070_INTEGRATION_TIME[self._it][0] << 2
185+
| 0x02
186+
)
177187
with self.i2c_cmd as i2c_cmd:
178188
i2c_cmd.write(self.buf)
179189

@@ -191,8 +201,12 @@ def ack_threshold(self, new_ack_thd):
191201
if new_ack_thd not in (0, 1):
192202
raise ValueError("ACK Threshold must be '0' or '1'.")
193203
self._ack_thd = int(new_ack_thd)
194-
self.buf[0] = (self._ack << 5 | self._ack_thd << 4 |
195-
_VEML6070_INTEGRATION_TIME[self._it][0] << 2 | 0x02)
204+
self.buf[0] = (
205+
self._ack << 5
206+
| self._ack_thd << 4
207+
| _VEML6070_INTEGRATION_TIME[self._it][0] << 2
208+
| 0x02
209+
)
196210
with self.i2c_cmd as i2c_cmd:
197211
i2c_cmd.write(self.buf)
198212

@@ -209,12 +223,18 @@ def integration_time(self):
209223
@integration_time.setter
210224
def integration_time(self, new_it):
211225
if new_it not in _VEML6070_INTEGRATION_TIME:
212-
raise ValueError("Integration Time invalid. Valid values are: ",
213-
_VEML6070_INTEGRATION_TIME.keys())
226+
raise ValueError(
227+
"Integration Time invalid. Valid values are: ",
228+
_VEML6070_INTEGRATION_TIME.keys(),
229+
)
214230

215231
self._it = new_it
216-
self.buf[0] = (self._ack << 5 | self._ack_thd << 4 |
217-
_VEML6070_INTEGRATION_TIME[new_it][0] << 2 | 0x02)
232+
self.buf[0] = (
233+
self._ack << 5
234+
| self._ack_thd << 4
235+
| _VEML6070_INTEGRATION_TIME[new_it][0] << 2
236+
| 0x02
237+
)
218238
with self.i2c_cmd as i2c_cmd:
219239
i2c_cmd.write(self.buf)
220240

@@ -231,8 +251,12 @@ def wake(self):
231251
"""
232252
Wakes the VEML6070 from sleep. ``[veml6070].uv_raw`` will also wake from sleep.
233253
"""
234-
self.buf[0] = (self._ack << 5 | self._ack_thd << 4 |
235-
_VEML6070_INTEGRATION_TIME[self._it][0] << 2 | 0x02)
254+
self.buf[0] = (
255+
self._ack << 5
256+
| self._ack_thd << 4
257+
| _VEML6070_INTEGRATION_TIME[self._it][0] << 2
258+
| 0x02
259+
)
236260
with self.i2c_cmd as i2c_cmd:
237261
i2c_cmd.write(self.buf)
238262

@@ -261,15 +285,16 @@ def get_index(self, _raw):
261285
if div == 0:
262286
raise ValueError(
263287
"[veml6070].get_index only available for Integration Times 1, 2, & 4.",
264-
"Use [veml6070].set_integration_time(new_it) to change the Integration Time."
265-
)
288+
"Use [veml6070].set_integration_time(new_it) to change the Integration Time.",
289+
)
266290

267291
# adjust the raw value using the divisor, then loop through the Risk Level dict
268292
# to find which range the adjusted raw value is in.
269293
raw_adj = int(_raw / div)
270294
for levels in _VEML6070_RISK_LEVEL:
271-
tmp_range = range(_VEML6070_RISK_LEVEL[levels][0],
272-
_VEML6070_RISK_LEVEL[levels][1])
295+
tmp_range = range(
296+
_VEML6070_RISK_LEVEL[levels][0], _VEML6070_RISK_LEVEL[levels][1]
297+
)
273298
if raw_adj in tmp_range:
274299
risk = levels
275300
break

docs/conf.py

Lines changed: 68 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,55 @@
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

1819
# Uncomment the below if you use native CircuitPython modules such as
1920
# digitalio, micropython and busio. List the modules you use. Without it, the
2021
# autodoc module docs will fail to generate with a warning.
2122
# autodoc_mock_imports = ["micropython", "adafruit_bus_device"]
2223

23-
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)}
24+
intersphinx_mapping = {
25+
"python": ("https://docs.python.org/3.4", None),
26+
"BusDevice": (
27+
"https://circuitpython.readthedocs.io/projects/busdevice/en/latest/",
28+
None,
29+
),
30+
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
31+
}
2432

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

28-
source_suffix = '.rst'
36+
source_suffix = ".rst"
2937

3038
# The master toctree document.
31-
master_doc = 'index'
39+
master_doc = "index"
3240

3341
# General information about the project.
34-
project = u'Adafruit VEML6070 Library'
35-
copyright = u'2017 Limor Fried & Michael Schroeder'
36-
author = u'Limor Fried & Michael Schroeder'
42+
project = u"Adafruit VEML6070 Library"
43+
copyright = u"2017 Limor Fried & Michael Schroeder"
44+
author = u"Limor Fried & Michael Schroeder"
3745

3846
# The version info for the project you're documenting, acts as replacement for
3947
# |version| and |release|, also used in various other places throughout the
4048
# built documents.
4149
#
4250
# The short X.Y version.
43-
version = u'1.0'
51+
version = u"1.0"
4452
# The full version, including alpha/beta/rc tags.
45-
release = u'1.0'
53+
release = u"1.0"
4654

4755
# The language for content autogenerated by Sphinx. Refer to documentation
4856
# for a list of supported languages.
@@ -54,7 +62,7 @@
5462
# List of patterns, relative to source directory, that match files and
5563
# directories to ignore when looking for source files.
5664
# This patterns also effect to html_static_path and html_extra_path
57-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
65+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
5866

5967
# The reST default role (used for this markup: `text`) to use for all
6068
# documents.
@@ -66,7 +74,7 @@
6674
add_function_parentheses = True
6775

6876
# The name of the Pygments (syntax highlighting) style to use.
69-
pygments_style = 'sphinx'
77+
pygments_style = "sphinx"
7078

7179
# If true, `todo` and `todoList` produce output, else they produce nothing.
7280
todo_include_todos = False
@@ -80,68 +88,76 @@
8088
# The theme to use for HTML and HTML Help pages. See the documentation for
8189
# a list of builtin themes.
8290
#
83-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
91+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
8492

8593
if not on_rtd: # only import and set the theme if we're building docs locally
8694
try:
8795
import sphinx_rtd_theme
88-
html_theme = 'sphinx_rtd_theme'
89-
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(), "."]
9099
except:
91-
html_theme = 'default'
92-
html_theme_path = ['.']
100+
html_theme = "default"
101+
html_theme_path = ["."]
93102
else:
94-
html_theme_path = ['.']
103+
html_theme_path = ["."]
95104

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

101110
# The name of an image file (relative to this directory) to use as a favicon of
102111
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
103112
# pixels large.
104113
#
105-
html_favicon = '_static/favicon.ico'
114+
html_favicon = "_static/favicon.ico"
106115

107116
# Output file base name for HTML help builder.
108-
htmlhelp_basename = 'AdafruitVeml6070Librarydoc'
117+
htmlhelp_basename = "AdafruitVeml6070Librarydoc"
109118

110119
# -- Options for LaTeX output ---------------------------------------------
111120

112121
latex_elements = {
113-
# The paper size ('letterpaper' or 'a4paper').
114-
#
115-
# 'papersize': 'letterpaper',
116-
117-
# The font size ('10pt', '11pt' or '12pt').
118-
#
119-
# 'pointsize': '10pt',
120-
121-
# Additional stuff for the LaTeX preamble.
122-
#
123-
# 'preamble': '',
124-
125-
# Latex figure (float) alignment
126-
#
127-
# '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',
128134
}
129135

130136
# Grouping the document tree into LaTeX files. List of tuples
131137
# (source start file, target name, title,
132138
# author, documentclass [howto, manual, or own class]).
133139
latex_documents = [
134-
(master_doc, 'AdafruitVEML6070Library.tex', u'AdafruitVEML6070 Library Documentation',
135-
author, 'manual'),
140+
(
141+
master_doc,
142+
"AdafruitVEML6070Library.tex",
143+
u"AdafruitVEML6070 Library Documentation",
144+
author,
145+
"manual",
146+
),
136147
]
137148

138149
# -- Options for manual page output ---------------------------------------
139150

140151
# One entry per manual page. List of tuples
141152
# (source start file, name, description, authors, manual section).
142153
man_pages = [
143-
(master_doc, 'AdafruitVEML6070library', u'Adafruit VEML6070 Library Documentation',
144-
[author], 1)
154+
(
155+
master_doc,
156+
"AdafruitVEML6070library",
157+
u"Adafruit VEML6070 Library Documentation",
158+
[author],
159+
1,
160+
)
145161
]
146162

147163
# -- Options for Texinfo output -------------------------------------------
@@ -150,7 +166,13 @@
150166
# (source start file, target name, title, author,
151167
# dir menu entry, description, category)
152168
texinfo_documents = [
153-
(master_doc, 'AdafruitVEML6070Library', u'Adafruit VEML6070 Library Documentation',
154-
author, 'AdafruitVEML6070Library', 'One line description of project.',
155-
'Miscellaneous'),
169+
(
170+
master_doc,
171+
"AdafruitVEML6070Library",
172+
u"Adafruit VEML6070 Library Documentation",
173+
author,
174+
"AdafruitVEML6070Library",
175+
"One line description of project.",
176+
"Miscellaneous",
177+
),
156178
]

0 commit comments

Comments
 (0)