Skip to content

Commit a7ff0f6

Browse files
committed
Ran black, updated to pylint 2.x
1 parent 9c45226 commit a7ff0f6

File tree

4 files changed

+95
-87
lines changed

4 files changed

+95
-87
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_am2320.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565

6666

6767
def _crc16(data):
68-
crc = 0xffff
68+
crc = 0xFFFF
6969
for byte in data:
7070
crc ^= byte
7171
for _ in range(8):
@@ -79,20 +79,17 @@ def _crc16(data):
7979

8080
class AM2320Exception(Exception):
8181
"""Base class for exceptions."""
82-
pass
8382

8483

8584
class AM2320DeviceNotFound(AM2320Exception, ValueError):
8685
"""Indicates that a device couldn't be found."""
87-
pass
8886

8987

9088
class AM2320ReadError(AM2320Exception, RuntimeError):
9189
"""indicates that valid data could not be read from the sensor.
9290
9391
This may be due to a regular I2C read failure, or due to a checksum
9492
mismatch."""
95-
pass
9693

9794

9895
class AM2320:
@@ -102,6 +99,7 @@ class AM2320:
10299
:param int address: (optional) The I2C address of the device.
103100
104101
"""
102+
105103
def __init__(self, i2c_bus, address=AM2320_DEFAULT_ADDR):
106104
for _ in range(3):
107105
# retry since we have to wake up the devices
@@ -111,7 +109,7 @@ def __init__(self, i2c_bus, address=AM2320_DEFAULT_ADDR):
111109
except ValueError:
112110
pass
113111
time.sleep(0.25)
114-
raise AM2320DeviceNotFound('AM2320 not found')
112+
raise AM2320DeviceNotFound("AM2320 not found")
115113

116114
def _read_register(self, register, length):
117115
with self._i2c as i2c:
@@ -127,17 +125,17 @@ def _read_register(self, register, length):
127125
# print("cmd: %s" % [hex(i) for i in cmd])
128126
i2c.write(bytes(cmd))
129127
time.sleep(0.002) # wait 2 ms for reply
130-
result = bytearray(length+4) # 2 bytes pre, 2 bytes crc
128+
result = bytearray(length + 4) # 2 bytes pre, 2 bytes crc
131129
i2c.readinto(result)
132130
# print("$%02X => %s" % (register, [hex(i) for i in result]))
133131
# Check preamble indicates correct readings
134132
if result[0] != 0x3 or result[1] != length:
135-
raise AM2320ReadError('I2C read failure')
133+
raise AM2320ReadError("I2C read failure")
136134
# Check CRC on all but last 2 bytes
137135
crc1 = struct.unpack("<H", bytes(result[-2:]))[0]
138136
crc2 = _crc16(result[0:-2])
139137
if crc1 != crc2:
140-
raise AM2320ReadError('CRC failure 0x%04X vs 0x%04X' % (crc1, crc2))
138+
raise AM2320ReadError("CRC failure 0x%04X vs 0x%04X" % (crc1, crc2))
141139
return result[2:-2]
142140

143141
@property
@@ -146,10 +144,10 @@ def temperature(self):
146144
temperature = struct.unpack(">H", self._read_register(AM2320_REG_TEMP_H, 2))[0]
147145
if temperature >= 32768:
148146
temperature = 32768 - temperature
149-
return temperature/10.0
147+
return temperature / 10.0
150148

151149
@property
152150
def relative_humidity(self):
153151
"""The measured relative humidity in percent."""
154152
humidity = struct.unpack(">H", self._read_register(AM2320_REG_HUM_H, 2))[0]
155-
return humidity/10.0
153+
return humidity / 10.0

docs/conf.py

Lines changed: 65 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,47 @@
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

19-
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
20+
intersphinx_mapping = {
21+
"python": ("https://docs.python.org/3.4", None),
22+
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
23+
}
2024

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

24-
source_suffix = '.rst'
28+
source_suffix = ".rst"
2529

2630
# The master toctree document.
27-
master_doc = 'index'
31+
master_doc = "index"
2832

2933
# General information about the project.
30-
project = u'Adafruit am2320 Library'
31-
copyright = u'2017 Limor Fried'
32-
author = u'Limor Fried'
34+
project = u"Adafruit am2320 Library"
35+
copyright = u"2017 Limor Fried"
36+
author = u"Limor Fried"
3337

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

4347
# The language for content autogenerated by Sphinx. Refer to documentation
4448
# for a list of supported languages.
@@ -50,7 +54,7 @@
5054
# List of patterns, relative to source directory, that match files and
5155
# directories to ignore when looking for source files.
5256
# This patterns also effect to html_static_path and html_extra_path
53-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
57+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
5458

5559
# The reST default role (used for this markup: `text`) to use for all
5660
# documents.
@@ -62,7 +66,7 @@
6266
add_function_parentheses = True
6367

6468
# The name of the Pygments (syntax highlighting) style to use.
65-
pygments_style = 'sphinx'
69+
pygments_style = "sphinx"
6670

6771
# If true, `todo` and `todoList` produce output, else they produce nothing.
6872
todo_include_todos = False
@@ -77,68 +81,76 @@
7781
# The theme to use for HTML and HTML Help pages. See the documentation for
7882
# a list of builtin themes.
7983
#
80-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
84+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
8185

8286
if not on_rtd: # only import and set the theme if we're building docs locally
8387
try:
8488
import sphinx_rtd_theme
85-
html_theme = 'sphinx_rtd_theme'
86-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
89+
90+
html_theme = "sphinx_rtd_theme"
91+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
8792
except:
88-
html_theme = 'default'
89-
html_theme_path = ['.']
93+
html_theme = "default"
94+
html_theme_path = ["."]
9095
else:
91-
html_theme_path = ['.']
96+
html_theme_path = ["."]
9297

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

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

104109
# Output file base name for HTML help builder.
105-
htmlhelp_basename = 'AdafruitAm2320Librarydoc'
110+
htmlhelp_basename = "AdafruitAm2320Librarydoc"
106111

107112
# -- Options for LaTeX output ---------------------------------------------
108113

109114
latex_elements = {
110-
# The paper size ('letterpaper' or 'a4paper').
111-
#
112-
# 'papersize': 'letterpaper',
113-
114-
# The font size ('10pt', '11pt' or '12pt').
115-
#
116-
# 'pointsize': '10pt',
117-
118-
# Additional stuff for the LaTeX preamble.
119-
#
120-
# 'preamble': '',
121-
122-
# Latex figure (float) alignment
123-
#
124-
# 'figure_align': 'htbp',
115+
# The paper size ('letterpaper' or 'a4paper').
116+
#
117+
# 'papersize': 'letterpaper',
118+
# The font size ('10pt', '11pt' or '12pt').
119+
#
120+
# 'pointsize': '10pt',
121+
# Additional stuff for the LaTeX preamble.
122+
#
123+
# 'preamble': '',
124+
# Latex figure (float) alignment
125+
#
126+
# 'figure_align': 'htbp',
125127
}
126128

127129
# Grouping the document tree into LaTeX files. List of tuples
128130
# (source start file, target name, title,
129131
# author, documentclass [howto, manual, or own class]).
130132
latex_documents = [
131-
(master_doc, 'Adafruitam2320Library.tex', u'Adafruitam2320 Library Documentation',
132-
author, 'manual'),
133+
(
134+
master_doc,
135+
"Adafruitam2320Library.tex",
136+
u"Adafruitam2320 Library Documentation",
137+
author,
138+
"manual",
139+
),
133140
]
134141

135142
# -- Options for manual page output ---------------------------------------
136143

137144
# One entry per manual page. List of tuples
138145
# (source start file, name, description, authors, manual section).
139146
man_pages = [
140-
(master_doc, 'Adafruitam2320library', u'Adafruit am2320 Library Documentation',
141-
[author], 1)
147+
(
148+
master_doc,
149+
"Adafruitam2320library",
150+
u"Adafruit am2320 Library Documentation",
151+
[author],
152+
1,
153+
)
142154
]
143155

144156
# -- Options for Texinfo output -------------------------------------------
@@ -147,7 +159,13 @@
147159
# (source start file, target name, title, author,
148160
# dir menu entry, description, category)
149161
texinfo_documents = [
150-
(master_doc, 'Adafruitam2320Library', u'Adafruit am2320 Library Documentation',
151-
author, 'Adafruitam2320Library', 'One line description of project.',
152-
'Miscellaneous'),
162+
(
163+
master_doc,
164+
"Adafruitam2320Library",
165+
u"Adafruit am2320 Library Documentation",
166+
author,
167+
"Adafruitam2320Library",
168+
"One line description of project.",
169+
"Miscellaneous",
170+
),
153171
]

setup.py

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,54 +7,46 @@
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-am2320',
22-
22+
name="adafruit-circuitpython-am2320",
2323
use_scm_version=True,
24-
setup_requires=['setuptools_scm'],
25-
26-
description='CircuitPython driver for the AM2320 temperature and humidity sensor.',
24+
setup_requires=["setuptools_scm"],
25+
description="CircuitPython driver for the AM2320 temperature and humidity 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_AM2320',
32-
29+
url="https://github.com/adafruit/Adafruit_CircuitPython_AM2320",
3330
# Author details
34-
author='Adafruit Industries',
35-
author_email='circuitpython@adafruit.com',
36-
37-
install_requires=['Adafruit-Blinka', 'adafruit-circuitpython-busdevice'],
38-
31+
author="Adafruit Industries",
32+
author_email="circuitpython@adafruit.com",
33+
install_requires=["Adafruit-Blinka", "adafruit-circuitpython-busdevice"],
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 am2320 temperature humidity hardware micropython circuitpython',
56-
48+
keywords="adafruit am2320 temperature humidity hardware micropython circuitpython",
5749
# You can just specify the packages manually here if your project is
5850
# simple. Or you can use find_packages().
59-
py_modules=['adafruit_am2320'],
51+
py_modules=["adafruit_am2320"],
6052
)

0 commit comments

Comments
 (0)