Skip to content

Commit eacd022

Browse files
authored
Merge pull request #15 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents d29ac5b + c29d4e3 commit eacd022

File tree

5 files changed

+150
-129
lines changed

5 files changed

+150
-129
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_tsl2591.py

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -51,49 +51,49 @@
5151
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_TSL2591.git"
5252

5353

54-
#pylint: disable=bad-whitespace
54+
# pylint: disable=bad-whitespace
5555
# Internal constants:
56-
_TSL2591_ADDR = const(0x29)
57-
_TSL2591_COMMAND_BIT = const(0xA0)
58-
_TSL2591_ENABLE_POWEROFF = const(0x00)
59-
_TSL2591_ENABLE_POWERON = const(0x01)
60-
_TSL2591_ENABLE_AEN = const(0x02)
61-
_TSL2591_ENABLE_AIEN = const(0x10)
62-
_TSL2591_ENABLE_NPIEN = const(0x80)
63-
_TSL2591_REGISTER_ENABLE = const(0x00)
64-
_TSL2591_REGISTER_CONTROL = const(0x01)
65-
_TSL2591_REGISTER_DEVICE_ID = const(0x12)
66-
_TSL2591_REGISTER_CHAN0_LOW = const(0x14)
67-
_TSL2591_REGISTER_CHAN1_LOW = const(0x16)
68-
_TSL2591_LUX_DF = 408.0
69-
_TSL2591_LUX_COEFB = 1.64
70-
_TSL2591_LUX_COEFC = 0.59
71-
_TSL2591_LUX_COEFD = 0.86
72-
_TSL2591_MAX_COUNT_100MS = const(36863) # 0x8FFF
73-
_TSL2591_MAX_COUNT = const(65535) # 0xFFFF
56+
_TSL2591_ADDR = const(0x29)
57+
_TSL2591_COMMAND_BIT = const(0xA0)
58+
_TSL2591_ENABLE_POWEROFF = const(0x00)
59+
_TSL2591_ENABLE_POWERON = const(0x01)
60+
_TSL2591_ENABLE_AEN = const(0x02)
61+
_TSL2591_ENABLE_AIEN = const(0x10)
62+
_TSL2591_ENABLE_NPIEN = const(0x80)
63+
_TSL2591_REGISTER_ENABLE = const(0x00)
64+
_TSL2591_REGISTER_CONTROL = const(0x01)
65+
_TSL2591_REGISTER_DEVICE_ID = const(0x12)
66+
_TSL2591_REGISTER_CHAN0_LOW = const(0x14)
67+
_TSL2591_REGISTER_CHAN1_LOW = const(0x16)
68+
_TSL2591_LUX_DF = 408.0
69+
_TSL2591_LUX_COEFB = 1.64
70+
_TSL2591_LUX_COEFC = 0.59
71+
_TSL2591_LUX_COEFD = 0.86
72+
_TSL2591_MAX_COUNT_100MS = const(36863) # 0x8FFF
73+
_TSL2591_MAX_COUNT = const(65535) # 0xFFFF
7474

7575
# User-facing constants:
76-
GAIN_LOW = 0x00 # low gain (1x)
76+
GAIN_LOW = 0x00 # low gain (1x)
7777
"""Low gain (1x)"""
78-
GAIN_MED = 0x10 # medium gain (25x)
78+
GAIN_MED = 0x10 # medium gain (25x)
7979
"""Medium gain (25x)"""
80-
GAIN_HIGH = 0x20 # medium gain (428x)
80+
GAIN_HIGH = 0x20 # medium gain (428x)
8181
"""High gain (428x)"""
82-
GAIN_MAX = 0x30 # max gain (9876x)
82+
GAIN_MAX = 0x30 # max gain (9876x)
8383
"""Max gain (9876x)"""
84-
INTEGRATIONTIME_100MS = 0x00 # 100 millis
84+
INTEGRATIONTIME_100MS = 0x00 # 100 millis
8585
"""100 millis"""
86-
INTEGRATIONTIME_200MS = 0x01 # 200 millis
86+
INTEGRATIONTIME_200MS = 0x01 # 200 millis
8787
"""200 millis"""
88-
INTEGRATIONTIME_300MS = 0x02 # 300 millis
88+
INTEGRATIONTIME_300MS = 0x02 # 300 millis
8989
"""300 millis"""
90-
INTEGRATIONTIME_400MS = 0x03 # 400 millis
90+
INTEGRATIONTIME_400MS = 0x03 # 400 millis
9191
"""400 millis"""
92-
INTEGRATIONTIME_500MS = 0x04 # 500 millis
92+
INTEGRATIONTIME_500MS = 0x04 # 500 millis
9393
"""500 millis"""
94-
INTEGRATIONTIME_600MS = 0x05 # 600 millis
94+
INTEGRATIONTIME_600MS = 0x05 # 600 millis
9595
"""600 millis"""
96-
#pylint: enable=bad-whitespace
96+
# pylint: enable=bad-whitespace
9797

9898

9999
class TSL2591:
@@ -113,7 +113,7 @@ def __init__(self, i2c, address=_TSL2591_ADDR):
113113
self._device = i2c_device.I2CDevice(i2c, address)
114114
# Verify the chip ID.
115115
if self._read_u8(_TSL2591_REGISTER_DEVICE_ID) != 0x50:
116-
raise RuntimeError('Failed to find TSL2591, check wiring!')
116+
raise RuntimeError("Failed to find TSL2591, check wiring!")
117117
# Set default gain and integration times.
118118
self.gain = GAIN_MED
119119
self.integration_time = INTEGRATIONTIME_100MS
@@ -130,7 +130,7 @@ def _read_u8(self, address):
130130

131131
# Disable invalid name check since pylint isn't smart enough to know LE
132132
# is an abbreviation for little-endian.
133-
#pylint: disable=invalid-name
133+
# pylint: disable=invalid-name
134134
def _read_u16LE(self, address):
135135
# Read a 16-bit little-endian unsigned value from the specified 8-bit
136136
# address.
@@ -139,7 +139,8 @@ def _read_u16LE(self, address):
139139
self._BUFFER[0] = (_TSL2591_COMMAND_BIT | address) & 0xFF
140140
i2c.write_then_readinto(self._BUFFER, self._BUFFER, out_end=1, in_end=2)
141141
return (self._BUFFER[1] << 8) | self._BUFFER[0]
142-
#pylint: enable=invalid-name
142+
143+
# pylint: enable=invalid-name
143144

144145
def _write_u8(self, address, val):
145146
# Write an 8-bit unsigned value to the specified 8-bit address.
@@ -151,9 +152,13 @@ def _write_u8(self, address, val):
151152

152153
def enable(self):
153154
"""Put the device in a fully powered enabled mode."""
154-
self._write_u8(_TSL2591_REGISTER_ENABLE, _TSL2591_ENABLE_POWERON | \
155-
_TSL2591_ENABLE_AEN | _TSL2591_ENABLE_AIEN | \
156-
_TSL2591_ENABLE_NPIEN)
155+
self._write_u8(
156+
_TSL2591_REGISTER_ENABLE,
157+
_TSL2591_ENABLE_POWERON
158+
| _TSL2591_ENABLE_AEN
159+
| _TSL2591_ENABLE_AIEN
160+
| _TSL2591_ENABLE_NPIEN,
161+
)
157162

158163
def disable(self):
159164
"""Disable the device and go into low power mode."""
@@ -260,7 +265,7 @@ def lux(self):
260265

261266
# Handle overflow.
262267
if channel_0 >= max_counts or channel_1 >= max_counts:
263-
raise RuntimeError('Overflow reading light channels!')
268+
raise RuntimeError("Overflow reading light channels!")
264269
# Calculate lux using same equation as Arduino library:
265270
# https://github.com/adafruit/Adafruit_TSL2591_Library/blob/master/Adafruit_TSL2591.cpp
266271
again = 1.0
@@ -272,5 +277,7 @@ def lux(self):
272277
again = 9876.0
273278
cpl = (atime * again) / _TSL2591_LUX_DF
274279
lux1 = (channel_0 - (_TSL2591_LUX_COEFB * channel_1)) / cpl
275-
lux2 = ((_TSL2591_LUX_COEFC * channel_0) - (_TSL2591_LUX_COEFD * channel_1)) / cpl
280+
lux2 = (
281+
(_TSL2591_LUX_COEFC * channel_0) - (_TSL2591_LUX_COEFD * channel_1)
282+
) / cpl
276283
return max(lux1, lux2)

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 TSL2591 Library'
35-
copyright = u'2017 Tony DiCola'
36-
author = u'Tony DiCola'
42+
project = u"Adafruit TSL2591 Library"
43+
copyright = u"2017 Tony DiCola"
44+
author = u"Tony DiCola"
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 = 'AdafruitTsl2591Librarydoc'
117+
htmlhelp_basename = "AdafruitTsl2591Librarydoc"
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, 'AdafruitTSL2591Library.tex', u'AdafruitTSL2591 Library Documentation',
135-
author, 'manual'),
140+
(
141+
master_doc,
142+
"AdafruitTSL2591Library.tex",
143+
u"AdafruitTSL2591 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, 'AdafruitTSL2591library', u'Adafruit TSL2591 Library Documentation',
144-
[author], 1)
154+
(
155+
master_doc,
156+
"AdafruitTSL2591library",
157+
u"Adafruit TSL2591 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, 'AdafruitTSL2591Library', u'Adafruit TSL2591 Library Documentation',
154-
author, 'AdafruitTSL2591Library', 'One line description of project.',
155-
'Miscellaneous'),
169+
(
170+
master_doc,
171+
"AdafruitTSL2591Library",
172+
u"Adafruit TSL2591 Library Documentation",
173+
author,
174+
"AdafruitTSL2591Library",
175+
"One line description of project.",
176+
"Miscellaneous",
177+
),
156178
]

0 commit comments

Comments
 (0)