Skip to content

Commit ff93de3

Browse files
authored
Merge pull request #9 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents b866b1f + 8bc9333 commit ff93de3

File tree

5 files changed

+121
-100
lines changed

5 files changed

+121
-100
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_vcnl4040.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class VCNL4040: # pylint: disable=too-few-public-methods
6161
:param busio.I2C i2c_bus: The I2C bus the VCNL4040 is connected to.
6262
6363
"""
64+
6465
# Ambient light sensor integration times
6566
ALS_80MS = const(0x0)
6667
ALS_160MS = const(0x1)
@@ -169,7 +170,6 @@ def proximity_low_interrupt(self):
169170
proximity drops below low threshold."""
170171
return self._get_and_clear_cached_interrupt_state(self.PS_IF_AWAY)
171172

172-
173173
led_current = RWBits(3, 0x04, 8, register_width=2)
174174
"""LED current selection setting, in mA. Options are LED_50MA, LED_75MA, LED_100MA, LED_120MA,
175175
LED_140MA, LED_160MA, LED_180MA, LED_200MA."""
@@ -205,14 +205,14 @@ def lux(self):
205205
print("Ambient light: %.2f lux"%sensor.lux)
206206
time.sleep(0.1)
207207
"""
208-
return self.light * (0.1 /(1 << self.light_integration_time))
209-
208+
return self.light * (0.1 / (1 << self.light_integration_time))
210209

211210
# ALS_CONF - ALS integration time, persistence, interrupt, function enable/disable
212211
light_shutdown = RWBit(0x00, 0, register_width=2)
213212
"""Ambient light sensor shutdown. When ``True``, ambient light data is disabled."""
214213

215214
_light_integration_time = RWBits(2, 0x00, 6, register_width=2)
215+
216216
@property
217217
def light_integration_time(self):
218218
"""Ambient light sensor integration time setting. Longer time has higher sensitivity.
@@ -240,16 +240,16 @@ def light_integration_time(self):
240240

241241
@light_integration_time.setter
242242
def light_integration_time(self, new_it):
243-
from time import sleep
243+
from time import sleep # pylint: disable=import-outside-toplevel
244+
244245
# IT values are in 0-3 -> 80-640ms
245-
old_it_ms = ((8<< self._light_integration_time)*10)
246-
new_it_ms = ((8<< new_it)*10)
246+
old_it_ms = (8 << self._light_integration_time) * 10
247+
new_it_ms = (8 << new_it) * 10
247248
it_delay_seconds = (old_it_ms + new_it_ms + 1) * 0.001
248249

249250
self._light_integration_time = new_it
250251
sleep(it_delay_seconds)
251252

252-
253253
light_interrupt = RWBit(0x00, 1, register_width=2)
254254
"""Ambient light sensor interrupt enable. ``True`` to enable, and ``False`` to disable."""
255255

@@ -271,10 +271,9 @@ def light_low_interrupt(self):
271271
"""Low interrupt event. Triggered when ambient light value drops below low threshold."""
272272
return self._get_and_clear_cached_interrupt_state(self.ALS_IF_L)
273273

274-
275274
_raw_white = ROUnaryStruct(0x0A, "<H")
276-
@property
277275

276+
@property
278277
def white(self):
279278
"""White light data scaled according to the current integration time and gain settings.
280279
@@ -294,25 +293,23 @@ def white(self):
294293
print("White light:", sensor.white)
295294
time.sleep(0.1)
296295
"""
297-
return self._raw_white * (0.1 /(1 << self.light_integration_time))
298-
296+
return self._raw_white * (0.1 / (1 << self.light_integration_time))
299297

300298
# PS_MS - White channel enable/disable, PS mode, PS protection setting, LED current
301299
# White_EN - PS_MS_H, 7th bit - White channel enable/disable
302300
white_shutdown = RWBit(0x04, 15, register_width=2)
303301
"""White light channel shutdown. When ``True``, white light data is disabled."""
304302

305-
306303
def __init__(self, i2c, address=0x60):
307304
self.i2c_device = i2cdevice.I2CDevice(i2c, address)
308305
if self._device_id != 0x186:
309306
raise RuntimeError("Failed to find VCNL4040 - check wiring!")
310307

311308
self.cached_interrupt_state = {
312-
self.ALS_IF_L : False,
313-
self.ALS_IF_H : False,
314-
self.PS_IF_CLOSE : False,
315-
self.PS_IF_AWAY : False
309+
self.ALS_IF_L: False,
310+
self.ALS_IF_H: False,
311+
self.PS_IF_CLOSE: False,
312+
self.PS_IF_AWAY: False,
316313
}
317314

318315
self.proximity_shutdown = False
@@ -323,7 +320,7 @@ def _update_interrupt_state(self):
323320
interrupts = [self.PS_IF_AWAY, self.PS_IF_CLOSE, self.ALS_IF_H, self.ALS_IF_L]
324321
new_interrupt_state = self.interrupt_state
325322
for interrupt in interrupts:
326-
new_state = (new_interrupt_state & (1 << interrupt) > 0)
323+
new_state = new_interrupt_state & (1 << interrupt) > 0
327324
if new_state:
328325
self.cached_interrupt_state[interrupt] = new_state
329326

docs/conf.py

Lines changed: 81 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,69 @@
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!
2021
# Uncomment the below if you use native CircuitPython modules such as
2122
# digitalio, micropython and busio. List the modules you use. Without it, the
2223
# autodoc module docs will fail to generate with a warning.
23-
autodoc_mock_imports = ["adafruit_register.i2c_struct", "adafruit_register.i2c_bits",
24-
"adafruit_register.i2c_bit", "micropython", "adafruit_bus_device", "adafruit_register"]
24+
autodoc_mock_imports = [
25+
"adafruit_register.i2c_struct",
26+
"adafruit_register.i2c_bits",
27+
"adafruit_register.i2c_bit",
28+
"micropython",
29+
"adafruit_bus_device",
30+
"adafruit_register",
31+
]
2532

2633

27-
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)}
34+
intersphinx_mapping = {
35+
"python": ("https://docs.python.org/3.4", None),
36+
"BusDevice": (
37+
"https://circuitpython.readthedocs.io/projects/busdevice/en/latest/",
38+
None,
39+
),
40+
"Register": (
41+
"https://circuitpython.readthedocs.io/projects/register/en/latest/",
42+
None,
43+
),
44+
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
45+
}
2846

2947
# Add any paths that contain templates here, relative to this directory.
30-
templates_path = ['_templates']
48+
templates_path = ["_templates"]
3149

32-
source_suffix = '.rst'
50+
source_suffix = ".rst"
3351

3452
# The master toctree document.
35-
master_doc = 'index'
53+
master_doc = "index"
3654

3755
# General information about the project.
38-
project = u'Adafruit VCNL4040 Library'
39-
copyright = u'2019 Kattni Rembor'
40-
author = u'Kattni Rembor'
56+
project = u"Adafruit VCNL4040 Library"
57+
copyright = u"2019 Kattni Rembor"
58+
author = u"Kattni Rembor"
4159

4260
# The version info for the project you're documenting, acts as replacement for
4361
# |version| and |release|, also used in various other places throughout the
4462
# built documents.
4563
#
4664
# The short X.Y version.
47-
version = u'1.0'
65+
version = u"1.0"
4866
# The full version, including alpha/beta/rc tags.
49-
release = u'1.0'
67+
release = u"1.0"
5068

5169
# The language for content autogenerated by Sphinx. Refer to documentation
5270
# for a list of supported languages.
@@ -58,7 +76,7 @@
5876
# List of patterns, relative to source directory, that match files and
5977
# directories to ignore when looking for source files.
6078
# This patterns also effect to html_static_path and html_extra_path
61-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
79+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
6280

6381
# The reST default role (used for this markup: `text`) to use for all
6482
# documents.
@@ -70,7 +88,7 @@
7088
add_function_parentheses = True
7189

7290
# The name of the Pygments (syntax highlighting) style to use.
73-
pygments_style = 'sphinx'
91+
pygments_style = "sphinx"
7492

7593
# If true, `todo` and `todoList` produce output, else they produce nothing.
7694
todo_include_todos = False
@@ -85,68 +103,76 @@
85103
# The theme to use for HTML and HTML Help pages. See the documentation for
86104
# a list of builtin themes.
87105
#
88-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
106+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
89107

90108
if not on_rtd: # only import and set the theme if we're building docs locally
91109
try:
92110
import sphinx_rtd_theme
93-
html_theme = 'sphinx_rtd_theme'
94-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
111+
112+
html_theme = "sphinx_rtd_theme"
113+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
95114
except:
96-
html_theme = 'default'
97-
html_theme_path = ['.']
115+
html_theme = "default"
116+
html_theme_path = ["."]
98117
else:
99-
html_theme_path = ['.']
118+
html_theme_path = ["."]
100119

101120
# Add any paths that contain custom static files (such as style sheets) here,
102121
# relative to this directory. They are copied after the builtin static files,
103122
# so a file named "default.css" will overwrite the builtin "default.css".
104-
html_static_path = ['_static']
123+
html_static_path = ["_static"]
105124

106125
# The name of an image file (relative to this directory) to use as a favicon of
107126
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
108127
# pixels large.
109128
#
110-
html_favicon = '_static/favicon.ico'
129+
html_favicon = "_static/favicon.ico"
111130

112131
# Output file base name for HTML help builder.
113-
htmlhelp_basename = 'AdafruitVcnl4040Librarydoc'
132+
htmlhelp_basename = "AdafruitVcnl4040Librarydoc"
114133

115134
# -- Options for LaTeX output ---------------------------------------------
116135

117136
latex_elements = {
118-
# The paper size ('letterpaper' or 'a4paper').
119-
#
120-
# 'papersize': 'letterpaper',
121-
122-
# The font size ('10pt', '11pt' or '12pt').
123-
#
124-
# 'pointsize': '10pt',
125-
126-
# Additional stuff for the LaTeX preamble.
127-
#
128-
# 'preamble': '',
129-
130-
# Latex figure (float) alignment
131-
#
132-
# 'figure_align': 'htbp',
137+
# The paper size ('letterpaper' or 'a4paper').
138+
#
139+
# 'papersize': 'letterpaper',
140+
# The font size ('10pt', '11pt' or '12pt').
141+
#
142+
# 'pointsize': '10pt',
143+
# Additional stuff for the LaTeX preamble.
144+
#
145+
# 'preamble': '',
146+
# Latex figure (float) alignment
147+
#
148+
# 'figure_align': 'htbp',
133149
}
134150

135151
# Grouping the document tree into LaTeX files. List of tuples
136152
# (source start file, target name, title,
137153
# author, documentclass [howto, manual, or own class]).
138154
latex_documents = [
139-
(master_doc, 'AdafruitVCNL4040Library.tex', u'AdafruitVCNL4040 Library Documentation',
140-
author, 'manual'),
155+
(
156+
master_doc,
157+
"AdafruitVCNL4040Library.tex",
158+
u"AdafruitVCNL4040 Library Documentation",
159+
author,
160+
"manual",
161+
),
141162
]
142163

143164
# -- Options for manual page output ---------------------------------------
144165

145166
# One entry per manual page. List of tuples
146167
# (source start file, name, description, authors, manual section).
147168
man_pages = [
148-
(master_doc, 'AdafruitVCNL4040library', u'Adafruit VCNL4040 Library Documentation',
149-
[author], 1)
169+
(
170+
master_doc,
171+
"AdafruitVCNL4040library",
172+
u"Adafruit VCNL4040 Library Documentation",
173+
[author],
174+
1,
175+
)
150176
]
151177

152178
# -- Options for Texinfo output -------------------------------------------
@@ -155,7 +181,13 @@
155181
# (source start file, target name, title, author,
156182
# dir menu entry, description, category)
157183
texinfo_documents = [
158-
(master_doc, 'AdafruitVCNL4040Library', u'Adafruit VCNL4040 Library Documentation',
159-
author, 'AdafruitVCNL4040Library', 'One line description of project.',
160-
'Miscellaneous'),
184+
(
185+
master_doc,
186+
"AdafruitVCNL4040Library",
187+
u"Adafruit VCNL4040 Library Documentation",
188+
author,
189+
"AdafruitVCNL4040Library",
190+
"One line description of project.",
191+
"Miscellaneous",
192+
),
161193
]

examples/vcnl4040_simpletest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88

99
while True:
1010
print("Proximity:", sensor.proximity)
11-
print("Light: %d lux"% sensor.lux)
11+
print("Light: %d lux" % sensor.lux)
1212
time.sleep(1.0)

0 commit comments

Comments
 (0)