Skip to content

Commit 129e29d

Browse files
authored
Merge pull request #8 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents 53d2fb5 + d5d15fc commit 129e29d

File tree

6 files changed

+127
-96
lines changed

6 files changed

+127
-96
lines changed

.github/workflows/build.yml

+1-1
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_pct2075.py

+26-14
Original file line numberDiff line numberDiff line change
@@ -50,36 +50,44 @@
5050
from adafruit_register.i2c_bits import RWBits
5151
from adafruit_register.i2c_bit import RWBit
5252
import adafruit_bus_device.i2c_device as i2cdevice
53+
5354
__version__ = "0.0.0-auto.0"
5455
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PCT2075.git"
5556
# pylint: disable=bad-whitespace, too-few-public-methods
56-
PCT2075_DEFAULT_ADDRESS = 0x37 # Address is configured with pins A0-A2
57+
PCT2075_DEFAULT_ADDRESS = 0x37 # Address is configured with pins A0-A2
58+
59+
PCT2075_REGISTER_TEMP = 0 # Temperature register (read-only)
60+
PCT2075_REGISTER_CONFIG = 1 # Configuration register
61+
PCT2075_REGISTER_THYST = 2 # Hysterisis register
62+
PCT2075_REGISTER_TOS = 3 # OS register
63+
PCT2075_REGISTER_TIDLE = 4 # Measurement idle time register
5764

58-
PCT2075_REGISTER_TEMP = 0 # Temperature register (read-only)
59-
PCT2075_REGISTER_CONFIG = 1 # Configuration register
60-
PCT2075_REGISTER_THYST = 2 # Hysterisis register
61-
PCT2075_REGISTER_TOS = 3 # OS register
62-
PCT2075_REGISTER_TIDLE = 4 # Measurement idle time register
6365

6466
class Mode:
6567
"""Options for `mode`"""
68+
6669
INTERRUPT = 1
6770
COMPARITOR = 0
6871

72+
6973
class FaultCount:
7074
"""Options for `faults_to_alert`"""
75+
7176
FAULT_1 = 0
7277
FAULT_2 = 1
7378
FAULT_4 = 2
7479
FAULT_6 = 3
7580

81+
7682
# pylint: enable=bad-whitespace, too-few-public-methods
7783

84+
7885
class PCT2075:
7986
"""Driver for the PCT2075 Digital Temperature Sensor and Thermal Watchdog.
8087
:param ~busio.I2C i2c_bus: The I2C bus the INA260 is connected to.
8188
:param address: The I2C device address for the sensor. Default is ``0x37``.
8289
"""
90+
8391
def __init__(self, i2c_bus, address=PCT2075_DEFAULT_ADDRESS):
8492
self.i2c_device = i2cdevice.I2CDevice(i2c_bus, address)
8593

@@ -107,7 +115,7 @@ def __init__(self, i2c_bus, address=PCT2075_DEFAULT_ADDRESS):
107115
@property
108116
def temperature(self):
109117
"""Returns the current temperature in degress celsius. Resolution is 0.125 degrees C"""
110-
return (self._temperature>>5) * 0.125
118+
return (self._temperature >> 5) * 0.125
111119

112120
@property
113121
def high_temperature_threshold(self):
@@ -117,21 +125,23 @@ def high_temperature_threshold(self):
117125

118126
@high_temperature_threshold.setter
119127
def high_temperature_threshold(self, value):
120-
self._high_temperature_threshold = (int(value * 2) << 7)
128+
self._high_temperature_threshold = int(value * 2) << 7
121129

122130
@property
123131
def temperature_hysteresis(self):
124132
"""The temperature hysteresis value defines the bottom of the temperature range in degrees
125133
C in which the temperature is still considered high". `temperature_hysteresis` must be
126134
lower than `high_temperature_threshold`. Resolution is 0.5 degrees C.
127135
"""
128-
return (self._temp_hysteresis >> 7) * 0.5
136+
return (self._temp_hysteresis >> 7) * 0.5
129137

130138
@temperature_hysteresis.setter
131139
def temperature_hysteresis(self, value):
132140
if value >= self.high_temperature_threshold:
133-
raise ValueError("temperature_hysteresis must be less than high_temperature_threshold")
134-
self._temp_hysteresis = (int(value * 2) << 7)
141+
raise ValueError(
142+
"temperature_hysteresis must be less than high_temperature_threshold"
143+
)
144+
self._temp_hysteresis = int(value * 2) << 7
135145

136146
@property
137147
def faults_to_alert(self):
@@ -158,6 +168,8 @@ def delay_between_measurements(self):
158168
@delay_between_measurements.setter
159169
def delay_between_measurements(self, value):
160170
if value > 3100 or value < 100 or value % 100 > 0:
161-
raise AttributeError(""""delay_between_measurements must be >= 100 or <= 3100\
162-
and a multiple of 100""")
163-
self._idle_time = int(value/100)
171+
raise AttributeError(
172+
""""delay_between_measurements must be >= 100 or <= 3100\
173+
and a multiple of 100"""
174+
)
175+
self._idle_time = int(value / 100)

docs/conf.py

+73-47
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
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

@@ -23,29 +24,40 @@
2324
autodoc_mock_imports = ["adafruit_register", "adafruit_bus_device"]
2425

2526

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)}
27+
intersphinx_mapping = {
28+
"python": ("https://docs.python.org/3.4", None),
29+
"BusDevice": (
30+
"https://circuitpython.readthedocs.io/projects/busdevice/en/latest/",
31+
None,
32+
),
33+
"Register": (
34+
"https://circuitpython.readthedocs.io/projects/register/en/latest/",
35+
None,
36+
),
37+
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
38+
}
2739

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

31-
source_suffix = '.rst'
43+
source_suffix = ".rst"
3244

3345
# The master toctree document.
34-
master_doc = 'index'
46+
master_doc = "index"
3547

3648
# General information about the project.
37-
project = u'Adafruit PCT2075 Library'
38-
copyright = u'2019 Bryan Siepert'
39-
author = u'Bryan Siepert'
49+
project = u"Adafruit PCT2075 Library"
50+
copyright = u"2019 Bryan Siepert"
51+
author = u"Bryan Siepert"
4052

4153
# The version info for the project you're documenting, acts as replacement for
4254
# |version| and |release|, also used in various other places throughout the
4355
# built documents.
4456
#
4557
# The short X.Y version.
46-
version = u'1.0'
58+
version = u"1.0"
4759
# The full version, including alpha/beta/rc tags.
48-
release = u'1.0'
60+
release = u"1.0"
4961

5062
# The language for content autogenerated by Sphinx. Refer to documentation
5163
# for a list of supported languages.
@@ -57,7 +69,7 @@
5769
# List of patterns, relative to source directory, that match files and
5870
# directories to ignore when looking for source files.
5971
# 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']
72+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
6173

6274
# The reST default role (used for this markup: `text`) to use for all
6375
# documents.
@@ -69,7 +81,7 @@
6981
add_function_parentheses = True
7082

7183
# The name of the Pygments (syntax highlighting) style to use.
72-
pygments_style = 'sphinx'
84+
pygments_style = "sphinx"
7385

7486
# If true, `todo` and `todoList` produce output, else they produce nothing.
7587
todo_include_todos = False
@@ -84,68 +96,76 @@
8496
# The theme to use for HTML and HTML Help pages. See the documentation for
8597
# a list of builtin themes.
8698
#
87-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
99+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
88100

89101
if not on_rtd: # only import and set the theme if we're building docs locally
90102
try:
91103
import sphinx_rtd_theme
92-
html_theme = 'sphinx_rtd_theme'
93-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
104+
105+
html_theme = "sphinx_rtd_theme"
106+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
94107
except:
95-
html_theme = 'default'
96-
html_theme_path = ['.']
108+
html_theme = "default"
109+
html_theme_path = ["."]
97110
else:
98-
html_theme_path = ['.']
111+
html_theme_path = ["."]
99112

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

105118
# The name of an image file (relative to this directory) to use as a favicon of
106119
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
107120
# pixels large.
108121
#
109-
html_favicon = '_static/favicon.ico'
122+
html_favicon = "_static/favicon.ico"
110123

111124
# Output file base name for HTML help builder.
112-
htmlhelp_basename = 'AdafruitPct2075Librarydoc'
125+
htmlhelp_basename = "AdafruitPct2075Librarydoc"
113126

114127
# -- Options for LaTeX output ---------------------------------------------
115128

116129
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',
130+
# The paper size ('letterpaper' or 'a4paper').
131+
#
132+
# 'papersize': 'letterpaper',
133+
# The font size ('10pt', '11pt' or '12pt').
134+
#
135+
# 'pointsize': '10pt',
136+
# Additional stuff for the LaTeX preamble.
137+
#
138+
# 'preamble': '',
139+
# Latex figure (float) alignment
140+
#
141+
# 'figure_align': 'htbp',
132142
}
133143

134144
# Grouping the document tree into LaTeX files. List of tuples
135145
# (source start file, target name, title,
136146
# author, documentclass [howto, manual, or own class]).
137147
latex_documents = [
138-
(master_doc, 'AdafruitPCT2075Library.tex', u'AdafruitPCT2075 Library Documentation',
139-
author, 'manual'),
148+
(
149+
master_doc,
150+
"AdafruitPCT2075Library.tex",
151+
u"AdafruitPCT2075 Library Documentation",
152+
author,
153+
"manual",
154+
),
140155
]
141156

142157
# -- Options for manual page output ---------------------------------------
143158

144159
# One entry per manual page. List of tuples
145160
# (source start file, name, description, authors, manual section).
146161
man_pages = [
147-
(master_doc, 'AdafruitPCT2075library', u'Adafruit PCT2075 Library Documentation',
148-
[author], 1)
162+
(
163+
master_doc,
164+
"AdafruitPCT2075library",
165+
u"Adafruit PCT2075 Library Documentation",
166+
[author],
167+
1,
168+
)
149169
]
150170

151171
# -- Options for Texinfo output -------------------------------------------
@@ -154,7 +174,13 @@
154174
# (source start file, target name, title, author,
155175
# dir menu entry, description, category)
156176
texinfo_documents = [
157-
(master_doc, 'AdafruitPCT2075Library', u'Adafruit PCT2075 Library Documentation',
158-
author, 'AdafruitPCT2075Library', 'One line description of project.',
159-
'Miscellaneous'),
177+
(
178+
master_doc,
179+
"AdafruitPCT2075Library",
180+
u"Adafruit PCT2075 Library Documentation",
181+
author,
182+
"AdafruitPCT2075Library",
183+
"One line description of project.",
184+
"Miscellaneous",
185+
),
160186
]

examples/pct2075_high_temp_alert_example.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
pct.high_temperature_threshold = 35.5
1010
pct.temperature_hysteresis = 30.0
1111
pct.high_temp_active_high = False
12-
print("High temp alert active high? %s"%pct.high_temp_active_high)
12+
print("High temp alert active high? %s" % pct.high_temp_active_high)
1313

1414
# Attach an LED with the Cathode to the INT pin and Anode to 3.3V with a current limiting resistor
1515

1616
while True:
17-
print("Temperature: %.2f C"%pct.temperature)
17+
print("Temperature: %.2f C" % pct.temperature)
1818
time.sleep(0.5)

examples/pct2075_simpletest.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
import board
33
import busio
44
import adafruit_pct2075
5+
56
i2c = busio.I2C(board.SCL, board.SDA)
67

78
pct = adafruit_pct2075.PCT2075(i2c)
89

910
while True:
10-
print("Temperature: %.2f C"%pct.temperature)
11+
print("Temperature: %.2f C" % pct.temperature)
1112
time.sleep(0.5)

0 commit comments

Comments
 (0)