Skip to content

Commit 1ac4e61

Browse files
committed
Ran black, updated to pylint 2.x
1 parent af64cfd commit 1ac4e61

File tree

7 files changed

+109
-96
lines changed

7 files changed

+109
-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

.pylintrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ spelling-store-unknown-words=no
119119
[MISCELLANEOUS]
120120

121121
# List of note tags to take in consideration, separated by a comma.
122-
notes=FIXME,XXX,TODO
122+
# notes=FIXME,XXX,TODO
123+
notes=FIXME,XXX
123124

124125

125126
[TYPECHECK]

adafruit_ds18x20.py

+18-16
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,19 @@
3232
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_DS18x20.git"
3333

3434
import time
35-
from adafruit_onewire.device import OneWireDevice
3635
from micropython import const
36+
from adafruit_onewire.device import OneWireDevice
3737

38-
_CONVERT = b'\x44'
39-
_RD_SCRATCH = b'\xBE'
40-
_WR_SCRATCH = b'\x4E'
38+
_CONVERT = b"\x44"
39+
_RD_SCRATCH = b"\xBE"
40+
_WR_SCRATCH = b"\x4E"
4141
_CONVERSION_TIMEOUT = const(1)
4242
RESOLUTION = (9, 10, 11, 12)
4343
# Maximum conversion delay in seconds, from DS18B20 datasheet.
44-
_CONVERSION_DELAY = {9:0.09375, 10:0.1875, 11:0.375, 12:0.750}
44+
_CONVERSION_DELAY = {9: 0.09375, 10: 0.1875, 11: 0.375, 12: 0.750}
4545

46-
class DS18X20(object):
46+
47+
class DS18X20:
4748
"""Class which provides interface to DS18X20 temperature sensor."""
4849

4950
def __init__(self, bus, address):
@@ -53,7 +54,7 @@ def __init__(self, bus, address):
5354
self._buf = bytearray(9)
5455
self._conv_delay = _CONVERSION_DELAY[12] # pessimistic default
5556
else:
56-
raise ValueError('Incorrect family code in device address.')
57+
raise ValueError("Incorrect family code in device address.")
5758

5859
@property
5960
def temperature(self):
@@ -69,10 +70,10 @@ def resolution(self):
6970
@resolution.setter
7071
def resolution(self, bits):
7172
if bits not in RESOLUTION:
72-
raise ValueError('Incorrect resolution. Must be 9, 10, 11, or 12.')
73+
raise ValueError("Incorrect resolution. Must be 9, 10, 11, or 12.")
7374
self._buf[0] = 0 # TH register
7475
self._buf[1] = 0 # TL register
75-
self._buf[2] = RESOLUTION.index(bits) << 5 | 0x1F # configuration register
76+
self._buf[2] = RESOLUTION.index(bits) << 5 | 0x1F # configuration register
7677
self._write_scratch(self._buf)
7778

7879
def _convert_temp(self, timeout=_CONVERSION_TIMEOUT):
@@ -84,7 +85,9 @@ def _convert_temp(self, timeout=_CONVERSION_TIMEOUT):
8485
# 0 = conversion in progress, 1 = conversion done
8586
while self._buf[0] == 0x00:
8687
if time.monotonic() - start_time > timeout:
87-
raise RuntimeError('Timeout waiting for conversion to complete.')
88+
raise RuntimeError(
89+
"Timeout waiting for conversion to complete."
90+
)
8891
dev.readinto(self._buf, end=1)
8992
return time.monotonic() - start_time
9093

@@ -94,15 +97,14 @@ def _read_temp(self):
9497
if self._address.family_code == 0x10:
9598
if buf[1]:
9699
t = buf[0] >> 1 | 0x80
97-
t = -((~t + 1) & 0xff)
100+
t = -((~t + 1) & 0xFF)
98101
else:
99102
t = buf[0] >> 1
100103
return t - 0.25 + (buf[7] - buf[6]) / buf[7]
101-
else:
102-
t = buf[1] << 8 | buf[0]
103-
if t & 0x8000: # sign bit set
104-
t = -((t ^ 0xffff) + 1)
105-
return t / 16
104+
t = buf[1] << 8 | buf[0]
105+
if t & 0x8000: # sign bit set
106+
t = -((t ^ 0xFFFF) + 1)
107+
return t / 16
106108

107109
def _read_scratch(self):
108110
with self._device as dev:

docs/conf.py

+64-46
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,51 @@
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 = ["adafruit_onewire", "micropython", "time"]
2223

23-
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
24+
intersphinx_mapping = {
25+
"python": ("https://docs.python.org/3.4", None),
26+
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
27+
}
2428

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

28-
source_suffix = '.rst'
32+
source_suffix = ".rst"
2933

3034
# The master toctree document.
31-
master_doc = 'index'
35+
master_doc = "index"
3236

3337
# General information about the project.
34-
project = u'Adafruit DS18X20 Library'
35-
copyright = u'2017 Carter Nelson'
36-
author = u'Carter Nelson'
38+
project = u"Adafruit DS18X20 Library"
39+
copyright = u"2017 Carter Nelson"
40+
author = u"Carter Nelson"
3741

3842
# The version info for the project you're documenting, acts as replacement for
3943
# |version| and |release|, also used in various other places throughout the
4044
# built documents.
4145
#
4246
# The short X.Y version.
43-
version = u'1.0'
47+
version = u"1.0"
4448
# The full version, including alpha/beta/rc tags.
45-
release = u'1.0'
49+
release = u"1.0"
4650

4751
# The language for content autogenerated by Sphinx. Refer to documentation
4852
# for a list of supported languages.
@@ -54,7 +58,7 @@
5458
# List of patterns, relative to source directory, that match files and
5559
# directories to ignore when looking for source files.
5660
# 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']
61+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
5862

5963
# The reST default role (used for this markup: `text`) to use for all
6064
# documents.
@@ -66,7 +70,7 @@
6670
add_function_parentheses = True
6771

6872
# The name of the Pygments (syntax highlighting) style to use.
69-
pygments_style = 'sphinx'
73+
pygments_style = "sphinx"
7074

7175
# If true, `todo` and `todoList` produce output, else they produce nothing.
7276
todo_include_todos = False
@@ -80,68 +84,76 @@
8084
# The theme to use for HTML and HTML Help pages. See the documentation for
8185
# a list of builtin themes.
8286
#
83-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
87+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
8488

8589
if not on_rtd: # only import and set the theme if we're building docs locally
8690
try:
8791
import sphinx_rtd_theme
88-
html_theme = 'sphinx_rtd_theme'
89-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
92+
93+
html_theme = "sphinx_rtd_theme"
94+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
9095
except:
91-
html_theme = 'default'
92-
html_theme_path = ['.']
96+
html_theme = "default"
97+
html_theme_path = ["."]
9398
else:
94-
html_theme_path = ['.']
99+
html_theme_path = ["."]
95100

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

101106
# The name of an image file (relative to this directory) to use as a favicon of
102107
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
103108
# pixels large.
104109
#
105-
html_favicon = '_static/favicon.ico'
110+
html_favicon = "_static/favicon.ico"
106111

107112
# Output file base name for HTML help builder.
108-
htmlhelp_basename = 'AdafruitDs18x20Librarydoc'
113+
htmlhelp_basename = "AdafruitDs18x20Librarydoc"
109114

110115
# -- Options for LaTeX output ---------------------------------------------
111116

112117
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',
118+
# The paper size ('letterpaper' or 'a4paper').
119+
#
120+
# 'papersize': 'letterpaper',
121+
# The font size ('10pt', '11pt' or '12pt').
122+
#
123+
# 'pointsize': '10pt',
124+
# Additional stuff for the LaTeX preamble.
125+
#
126+
# 'preamble': '',
127+
# Latex figure (float) alignment
128+
#
129+
# 'figure_align': 'htbp',
128130
}
129131

130132
# Grouping the document tree into LaTeX files. List of tuples
131133
# (source start file, target name, title,
132134
# author, documentclass [howto, manual, or own class]).
133135
latex_documents = [
134-
(master_doc, 'AdafruitDS18X20Library.tex', u'AdafruitDS18X20 Library Documentation',
135-
author, 'manual'),
136+
(
137+
master_doc,
138+
"AdafruitDS18X20Library.tex",
139+
u"AdafruitDS18X20 Library Documentation",
140+
author,
141+
"manual",
142+
),
136143
]
137144

138145
# -- Options for manual page output ---------------------------------------
139146

140147
# One entry per manual page. List of tuples
141148
# (source start file, name, description, authors, manual section).
142149
man_pages = [
143-
(master_doc, 'AdafruitDS18X20library', u'Adafruit DS18X20 Library Documentation',
144-
[author], 1)
150+
(
151+
master_doc,
152+
"AdafruitDS18X20library",
153+
u"Adafruit DS18X20 Library Documentation",
154+
[author],
155+
1,
156+
)
145157
]
146158

147159
# -- Options for Texinfo output -------------------------------------------
@@ -150,7 +162,13 @@
150162
# (source start file, target name, title, author,
151163
# dir menu entry, description, category)
152164
texinfo_documents = [
153-
(master_doc, 'AdafruitDS18X20Library', u'Adafruit DS18X20 Library Documentation',
154-
author, 'AdafruitDS18X20Library', 'One line description of project.',
155-
'Miscellaneous'),
165+
(
166+
master_doc,
167+
"AdafruitDS18X20Library",
168+
u"Adafruit DS18X20 Library Documentation",
169+
author,
170+
"AdafruitDS18X20Library",
171+
"One line description of project.",
172+
"Miscellaneous",
173+
),
156174
]

examples/ds18x20_asynctest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@
2727
while time.monotonic() < conversion_ready_at:
2828
print(".", end="")
2929
time.sleep(0.1)
30-
print('\nTemperature: {0:0.3f}C\n'.format(ds18.read_temperature()))
30+
print("\nTemperature: {0:0.3f}C\n".format(ds18.read_temperature()))
3131
time.sleep(1.0)

examples/ds18x20_simpletest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717

1818
# Main loop to print the temperature every second.
1919
while True:
20-
print('Temperature: {0:0.3f}C'.format(ds18.temperature))
20+
print("Temperature: {0:0.3f}C".format(ds18.temperature))
2121
time.sleep(1.0)

setup.py

+22-30
Original file line numberDiff line numberDiff line change
@@ -7,55 +7,47 @@
77

88
# Always prefer setuptools over distutils
99
from setuptools import setup, find_packages
10+
1011
# To use a consistent encoding
1112
from codecs import open
1213
from os import path
1314

1415
here = path.abspath(path.dirname(__file__))
1516

1617
# Get the long description from the README file
17-
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
18+
with open(path.join(here, "README.rst"), encoding="utf-8") as f:
1819
long_description = f.read()
1920

2021
setup(
21-
name='adafruit-circuitpython-ds18x20',
22-
22+
name="adafruit-circuitpython-ds18x20",
2323
use_scm_version=True,
24-
setup_requires=['setuptools_scm'],
25-
26-
description='CircuitPython driver for Dallas 1-Wire temperature sensor.',
24+
setup_requires=["setuptools_scm"],
25+
description="CircuitPython driver for Dallas 1-Wire temperature sensor.",
2726
long_description=long_description,
28-
long_description_content_type='text/x-rst',
29-
27+
long_description_content_type="text/x-rst",
3028
# The project's main homepage.
31-
url='https://github.com/adafruit/Adafruit_CircuitPython_DS18X20',
32-
29+
url="https://github.com/adafruit/Adafruit_CircuitPython_DS18X20",
3330
# Author details
34-
author='Adafruit Industries',
35-
author_email='[email protected]',
36-
37-
install_requires=['Adafruit-Blinka', 'adafruit-circuitpython-onewire'],
38-
31+
author="Adafruit Industries",
32+
author_email="[email protected]",
33+
install_requires=["Adafruit-Blinka", "adafruit-circuitpython-onewire"],
3934
# Choose your license
40-
license='MIT',
41-
35+
license="MIT",
4236
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
4337
classifiers=[
44-
'Development Status :: 3 - Alpha',
45-
'Intended Audience :: Developers',
46-
'Topic :: Software Development :: Libraries',
47-
'Topic :: System :: Hardware',
48-
'License :: OSI Approved :: MIT License',
49-
'Programming Language :: Python :: 3',
50-
'Programming Language :: Python :: 3.4',
51-
'Programming Language :: Python :: 3.5',
38+
"Development Status :: 3 - Alpha",
39+
"Intended Audience :: Developers",
40+
"Topic :: Software Development :: Libraries",
41+
"Topic :: System :: Hardware",
42+
"License :: OSI Approved :: MIT License",
43+
"Programming Language :: Python :: 3",
44+
"Programming Language :: Python :: 3.4",
45+
"Programming Language :: Python :: 3.5",
5246
],
53-
5447
# What does your project relate to?
55-
keywords='adafruit 1-wire temperature sensor ds18x20 '
56-
'hardware breakout micropython circuitpython',
57-
48+
keywords="adafruit 1-wire temperature sensor ds18x20 "
49+
"hardware breakout micropython circuitpython",
5850
# You can just specify the packages manually here if your project is
5951
# simple. Or you can use find_packages().
60-
py_modules=['adafruit_ds18x20'],
52+
py_modules=["adafruit_ds18x20"],
6153
)

0 commit comments

Comments
 (0)