Skip to content

Commit 12733ac

Browse files
authored
Merge pull request #10 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents 8312303 + f2fde99 commit 12733ac

File tree

7 files changed

+156
-123
lines changed

7 files changed

+156
-123
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_ina260.py

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@
5656
from adafruit_register.i2c_bits import RWBits
5757
from adafruit_register.i2c_bit import ROBit
5858

59-
# pylint: disable=bad-whitespace
60-
_REG_CONFIG = const(0x00) # CONFIGURATION REGISTER (R/W)
61-
_REG_CURRENT = const(0x01) # SHUNT VOLTAGE REGISTER (R)
62-
_REG_BUSVOLTAGE = const(0x02) # BUS VOLTAGE REGISTER (R)
63-
_REG_POWER = const(0x03) # POWER REGISTER (R)
64-
_REG_MASK_ENABLE = const(0x06) # MASK ENABLE REGISTER (R/W)
65-
_REG_ALERT_LIMIT = const(0x07) # ALERT LIMIT REGISTER (R/W)
66-
_REG_MFG_UID = const(0xFE) # MANUFACTURER UNIQUE ID REGISTER (R)
67-
_REG_DIE_UID = const(0xFF)# DIE UNIQUE ID REGISTER (R)
59+
# pylint: disable=bad-whitespace
60+
_REG_CONFIG = const(0x00) # CONFIGURATION REGISTER (R/W)
61+
_REG_CURRENT = const(0x01) # SHUNT VOLTAGE REGISTER (R)
62+
_REG_BUSVOLTAGE = const(0x02) # BUS VOLTAGE REGISTER (R)
63+
_REG_POWER = const(0x03) # POWER REGISTER (R)
64+
_REG_MASK_ENABLE = const(0x06) # MASK ENABLE REGISTER (R/W)
65+
_REG_ALERT_LIMIT = const(0x07) # ALERT LIMIT REGISTER (R/W)
66+
_REG_MFG_UID = const(0xFE) # MANUFACTURER UNIQUE ID REGISTER (R)
67+
_REG_DIE_UID = const(0xFF) # DIE UNIQUE ID REGISTER (R)
6868

6969
# pylint: disable=too-few-public-methods
7070
class Mode:
@@ -86,10 +86,12 @@ class Mode:
8686
+--------------------+---------------------------------------------------------------------+
8787
8888
"""
89-
SHUTDOWN = const(0x0)
90-
TRIGGERED = const(0x3)
89+
90+
SHUTDOWN = const(0x0)
91+
TRIGGERED = const(0x3)
9192
CONTINUOUS = const(0x7)
9293

94+
9395
class ConversionTime:
9496
"""Options for ``current_conversion_time`` or ``voltage_conversion_time``
9597
@@ -114,15 +116,17 @@ class ConversionTime:
114116
+----------------------------------+------------------+
115117
116118
"""
117-
TIME_140_us = const(0x0)
118-
TIME_204_us = const(0x1)
119-
TIME_332_us = const(0x2)
120-
TIME_558_us = const(0x3)
121-
TIME_1_1_ms = const(0x4)
119+
120+
TIME_140_us = const(0x0)
121+
TIME_204_us = const(0x1)
122+
TIME_332_us = const(0x2)
123+
TIME_558_us = const(0x3)
124+
TIME_1_1_ms = const(0x4)
122125
TIME_2_116_ms = const(0x5)
123126
TIME_4_156_ms = const(0x6)
124127
TIME_8_244_ms = const(0x7)
125128

129+
126130
class AveragingCount:
127131
"""Options for ``averaging_count``
128132
@@ -147,17 +151,21 @@ class AveragingCount:
147151
+-------------------------------+------------------------------------+
148152
149153
"""
150-
COUNT_1 = const(0x1)
151-
COUNT_4 = const(0x2)
152-
COUNT_16 = const(0x3)
153-
COUNT_64 = const(0x4)
154-
COUNT_128 = const(0x5)
155-
COUNT_256 = const(0x6)
156-
COUNT_512 = const(0x7)
154+
155+
COUNT_1 = const(0x1)
156+
COUNT_4 = const(0x2)
157+
COUNT_16 = const(0x3)
158+
COUNT_64 = const(0x4)
159+
COUNT_128 = const(0x5)
160+
COUNT_256 = const(0x6)
161+
COUNT_512 = const(0x7)
157162
COUNT_1024 = const(0x8)
163+
164+
158165
# pylint: enable=bad-whitespace
159166
# pylint: enable=too-few-public-methods
160167

168+
161169
class INA260:
162170
"""Driver for the INA260 power and current sensor.
163171

docs/conf.py

Lines changed: 79 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,67 @@
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 = ["micropython", "busio", "adafruit_bus_device", "adafruit_register"]
24+
autodoc_mock_imports = [
25+
"micropython",
26+
"busio",
27+
"adafruit_bus_device",
28+
"adafruit_register",
29+
]
2430

2531

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

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

31-
source_suffix = '.rst'
48+
source_suffix = ".rst"
3249

3350
# The master toctree document.
34-
master_doc = 'index'
51+
master_doc = "index"
3552

3653
# General information about the project.
37-
project = u'Adafruit INA260 Library'
38-
copyright = u'2019 Bryan Siepert'
39-
author = u'Bryan Siepert'
54+
project = u"Adafruit INA260 Library"
55+
copyright = u"2019 Bryan Siepert"
56+
author = u"Bryan Siepert"
4057

4158
# The version info for the project you're documenting, acts as replacement for
4259
# |version| and |release|, also used in various other places throughout the
4360
# built documents.
4461
#
4562
# The short X.Y version.
46-
version = u'1.0'
63+
version = u"1.0"
4764
# The full version, including alpha/beta/rc tags.
48-
release = u'1.0'
65+
release = u"1.0"
4966

5067
# The language for content autogenerated by Sphinx. Refer to documentation
5168
# for a list of supported languages.
@@ -57,7 +74,7 @@
5774
# List of patterns, relative to source directory, that match files and
5875
# directories to ignore when looking for source files.
5976
# 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']
77+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
6178

6279
# The reST default role (used for this markup: `text`) to use for all
6380
# documents.
@@ -69,7 +86,7 @@
6986
add_function_parentheses = True
7087

7188
# The name of the Pygments (syntax highlighting) style to use.
72-
pygments_style = 'sphinx'
89+
pygments_style = "sphinx"
7390

7491
# If true, `todo` and `todoList` produce output, else they produce nothing.
7592
todo_include_todos = False
@@ -84,68 +101,76 @@
84101
# The theme to use for HTML and HTML Help pages. See the documentation for
85102
# a list of builtin themes.
86103
#
87-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
104+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
88105

89106
if not on_rtd: # only import and set the theme if we're building docs locally
90107
try:
91108
import sphinx_rtd_theme
92-
html_theme = 'sphinx_rtd_theme'
93-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
109+
110+
html_theme = "sphinx_rtd_theme"
111+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
94112
except:
95-
html_theme = 'default'
96-
html_theme_path = ['.']
113+
html_theme = "default"
114+
html_theme_path = ["."]
97115
else:
98-
html_theme_path = ['.']
116+
html_theme_path = ["."]
99117

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

105123
# The name of an image file (relative to this directory) to use as a favicon of
106124
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
107125
# pixels large.
108126
#
109-
html_favicon = '_static/favicon.ico'
127+
html_favicon = "_static/favicon.ico"
110128

111129
# Output file base name for HTML help builder.
112-
htmlhelp_basename = 'AdafruitIna260Librarydoc'
130+
htmlhelp_basename = "AdafruitIna260Librarydoc"
113131

114132
# -- Options for LaTeX output ---------------------------------------------
115133

116134
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',
135+
# The paper size ('letterpaper' or 'a4paper').
136+
#
137+
# 'papersize': 'letterpaper',
138+
# The font size ('10pt', '11pt' or '12pt').
139+
#
140+
# 'pointsize': '10pt',
141+
# Additional stuff for the LaTeX preamble.
142+
#
143+
# 'preamble': '',
144+
# Latex figure (float) alignment
145+
#
146+
# 'figure_align': 'htbp',
132147
}
133148

134149
# Grouping the document tree into LaTeX files. List of tuples
135150
# (source start file, target name, title,
136151
# author, documentclass [howto, manual, or own class]).
137152
latex_documents = [
138-
(master_doc, 'AdafruitINA260Library.tex', u'AdafruitINA260 Library Documentation',
139-
author, 'manual'),
153+
(
154+
master_doc,
155+
"AdafruitINA260Library.tex",
156+
u"AdafruitINA260 Library Documentation",
157+
author,
158+
"manual",
159+
),
140160
]
141161

142162
# -- Options for manual page output ---------------------------------------
143163

144164
# One entry per manual page. List of tuples
145165
# (source start file, name, description, authors, manual section).
146166
man_pages = [
147-
(master_doc, 'AdafruitINA260library', u'Adafruit INA260 Library Documentation',
148-
[author], 1)
167+
(
168+
master_doc,
169+
"AdafruitINA260library",
170+
u"Adafruit INA260 Library Documentation",
171+
[author],
172+
1,
173+
)
149174
]
150175

151176
# -- Options for Texinfo output -------------------------------------------
@@ -154,7 +179,13 @@
154179
# (source start file, target name, title, author,
155180
# dir menu entry, description, category)
156181
texinfo_documents = [
157-
(master_doc, 'AdafruitINA260Library', u'Adafruit INA260 Library Documentation',
158-
author, 'AdafruitINA260Library', 'One line description of project.',
159-
'Miscellaneous'),
182+
(
183+
master_doc,
184+
"AdafruitINA260Library",
185+
u"Adafruit INA260 Library Documentation",
186+
author,
187+
"AdafruitINA260Library",
188+
"One line description of project.",
189+
"Miscellaneous",
190+
),
160191
]

examples/ina260_averaging.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
# Raise the averaging count to a larger number to smooth out the results
99
ina260.averaging_count = AveragingCount.COUNT_4
1010
while True:
11-
print("Current (average count 4): %.2f"%(ina260.current))
12-
print("Voltage (average count 4): %.2f"%(ina260.voltage))
13-
print("Power (average count 4): %.2f"%(ina260.power))
11+
print("Current (average count 4): %.2f" % (ina260.current))
12+
print("Voltage (average count 4): %.2f" % (ina260.voltage))
13+
print("Power (average count 4): %.2f" % (ina260.power))
1414

1515
time.sleep(1)
1616

examples/ina260_modes.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,33 @@
77

88
# trigger a sample
99
ina260.mode = Mode.TRIGGERED
10-
print("Current (one shot #1): %.2f"%(ina260.current))
11-
print("Voltage (one shot #1): %.2f"%(ina260.voltage))
12-
print("Power (one shot #1): %.2f"%(ina260.power))
10+
print("Current (one shot #1): %.2f" % (ina260.current))
11+
print("Voltage (one shot #1): %.2f" % (ina260.voltage))
12+
print("Power (one shot #1): %.2f" % (ina260.power))
1313

1414
# print it again to show it will return the same value
1515
# until triggered again
16-
print("Current (one shot #1 redux): %.2f"%(ina260.current))
17-
print("Voltage (one shot #1 redux): %.2f"%(ina260.voltage))
18-
print("Power (one shot #1 redux): %.2f"%(ina260.power))
16+
print("Current (one shot #1 redux): %.2f" % (ina260.current))
17+
print("Voltage (one shot #1 redux): %.2f" % (ina260.voltage))
18+
print("Power (one shot #1 redux): %.2f" % (ina260.power))
1919

2020
# trigger a second sample
2121
ina260.mode = Mode.TRIGGERED
22-
print("Current (one shot #2): %.2f"%(ina260.current))
23-
print("Voltage (one shot #2): %.2f"%(ina260.voltage))
24-
print("Power (one shot #2): %.2f"%(ina260.power))
22+
print("Current (one shot #2): %.2f" % (ina260.current))
23+
print("Voltage (one shot #2): %.2f" % (ina260.voltage))
24+
print("Power (one shot #2): %.2f" % (ina260.power))
2525

2626
# put the sensor in power-down mode. It will return
2727
# the previous value until a new mode is chosen
2828
ina260.mode = Mode.SHUTDOWN
29-
print("Current (shutdown): %.2f"%(ina260.current))
30-
print("Voltage (shutdown): %.2f"%(ina260.voltage))
31-
print("Power (shutdown): %.2f"%(ina260.power))
29+
print("Current (shutdown): %.2f" % (ina260.current))
30+
print("Voltage (shutdown): %.2f" % (ina260.voltage))
31+
print("Power (shutdown): %.2f" % (ina260.power))
3232

3333
# return the sensor to the default continuous mode
3434
ina260.mode = Mode.CONTINUOUS
3535
while True:
36-
print("Current (continuous): %.2f"%(ina260.current))
37-
print("Voltage (continuous): %.2f"%(ina260.voltage))
38-
print("Power (continuous): %.2f"%(ina260.power))
36+
print("Current (continuous): %.2f" % (ina260.current))
37+
print("Voltage (continuous): %.2f" % (ina260.voltage))
38+
print("Power (continuous): %.2f" % (ina260.power))
3939
time.sleep(1)

examples/ina260_simpletest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
i2c = board.I2C()
66
ina260 = adafruit_ina260.INA260(i2c)
77
while True:
8-
print("Current: %.2f mA Voltage: %.2f V Power:%.2f mW"
9-
%(ina260.current, ina260.voltage, ina260.power))
8+
print(
9+
"Current: %.2f mA Voltage: %.2f V Power:%.2f mW"
10+
% (ina260.current, ina260.voltage, ina260.power)
11+
)
1012
time.sleep(1)

0 commit comments

Comments
 (0)