Skip to content

Commit 41ce266

Browse files
authored
Merge pull request #11 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents 75da446 + c9d959c commit 41ce266

File tree

5 files changed

+118
-103
lines changed

5 files changed

+118
-103
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_vcnl4010.py

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,29 +53,29 @@
5353

5454
# pylint: disable=bad-whitespace
5555
# Internal constants:
56-
_VCNL4010_I2CADDR_DEFAULT = const(0x13)
57-
_VCNL4010_COMMAND = const(0x80)
58-
_VCNL4010_PRODUCTID = const(0x81)
59-
_VCNL4010_PROXRATE = const(0x82)
60-
_VCNL4010_IRLED = const(0x83)
61-
_VCNL4010_AMBIENTPARAMETER = const(0x84)
62-
_VCNL4010_AMBIENTDATA = const(0x85)
63-
_VCNL4010_PROXIMITYDATA = const(0x87)
64-
_VCNL4010_INTCONTROL = const(0x89)
65-
_VCNL4010_PROXINITYADJUST = const(0x8A)
66-
_VCNL4010_INTSTAT = const(0x8E)
67-
_VCNL4010_MODTIMING = const(0x8F)
68-
_VCNL4010_MEASUREAMBIENT = const(0x10)
69-
_VCNL4010_MEASUREPROXIMITY = const(0x08)
70-
_VCNL4010_AMBIENTREADY = const(0x40)
71-
_VCNL4010_PROXIMITYREADY = const(0x20)
56+
_VCNL4010_I2CADDR_DEFAULT = const(0x13)
57+
_VCNL4010_COMMAND = const(0x80)
58+
_VCNL4010_PRODUCTID = const(0x81)
59+
_VCNL4010_PROXRATE = const(0x82)
60+
_VCNL4010_IRLED = const(0x83)
61+
_VCNL4010_AMBIENTPARAMETER = const(0x84)
62+
_VCNL4010_AMBIENTDATA = const(0x85)
63+
_VCNL4010_PROXIMITYDATA = const(0x87)
64+
_VCNL4010_INTCONTROL = const(0x89)
65+
_VCNL4010_PROXINITYADJUST = const(0x8A)
66+
_VCNL4010_INTSTAT = const(0x8E)
67+
_VCNL4010_MODTIMING = const(0x8F)
68+
_VCNL4010_MEASUREAMBIENT = const(0x10)
69+
_VCNL4010_MEASUREPROXIMITY = const(0x08)
70+
_VCNL4010_AMBIENTREADY = const(0x40)
71+
_VCNL4010_PROXIMITYREADY = const(0x20)
7272
_VCNL4010_AMBIENT_LUX_SCALE = 0.25 # Lux value per 16-bit result value.
7373

7474
# User-facing constants:
75-
FREQUENCY_3M125 = 3
76-
FREQUENCY_1M5625 = 2
77-
FREQUENCY_781K25 = 1
78-
FREQUENCY_390K625 = 0
75+
FREQUENCY_3M125 = 3
76+
FREQUENCY_1M5625 = 2
77+
FREQUENCY_781K25 = 1
78+
FREQUENCY_390K625 = 0
7979
# pylint: enable=bad-whitespace
8080

8181
# Disable pylint's name warning as it causes too much noise. Suffixes like
@@ -98,7 +98,7 @@ def __init__(self, i2c, address=_VCNL4010_I2CADDR_DEFAULT):
9898
# Verify chip ID.
9999
revision = self._read_u8(_VCNL4010_PRODUCTID)
100100
if (revision & 0xF0) != 0x20:
101-
raise RuntimeError('Failed to find VCNL4010, check wiring!')
101+
raise RuntimeError("Failed to find VCNL4010, check wiring!")
102102
self.led_current = 20
103103
self.frequency = FREQUENCY_390K625
104104
self._write_u8(_VCNL4010_INTCONTROL, 0x08)
@@ -218,6 +218,7 @@ def ambient(self):
218218
result = self._read_u8(_VCNL4010_COMMAND)
219219
if result & _VCNL4010_AMBIENTREADY:
220220
return self._read_u16BE(_VCNL4010_AMBIENTDATA)
221+
221222
# pylint: enable=inconsistent-return-statements
222223

223224
@property

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

examples/vcnl4010_simpletest.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@
1515

1616
# You can optionally adjust the sensor LED current. The default is 200mA
1717
# which is the maximum value. Note this is only set in 10mA increments.
18-
#sensor.led_current_mA = 120 # Set 120 mA LED current
18+
# sensor.led_current_mA = 120 # Set 120 mA LED current
1919

2020
# You can also adjust the measurement frequency for the sensor. The default
2121
# is 390.625 khz, but these values are possible to set too:
2222
# - FREQUENCY_3M125: 3.125 Mhz
2323
# - FREQUENCY_1M5625: 1.5625 Mhz
2424
# - FREQUENCY_781K25: 781.25 Khz
2525
# - FREQUENCY_390K625: 390.625 Khz (default)
26-
#sensor.frequency = adafruit_vcnl4010.FREQUENCY_3M125 # 3.125 Mhz
26+
# sensor.frequency = adafruit_vcnl4010.FREQUENCY_3M125 # 3.125 Mhz
2727

2828
# Main loop runs forever printing the proximity and light level.
2929
while True:
3030
proximity = sensor.proximity # Proximity has no units and is a 16-bit
31-
# value. The LOWER the value the further
32-
# an object from the sensor (up to ~200mm).
33-
print('Proximity: {0}'.format(proximity))
31+
# value. The LOWER the value the further
32+
# an object from the sensor (up to ~200mm).
33+
print("Proximity: {0}".format(proximity))
3434
ambient_lux = sensor.ambient_lux
35-
print('Ambient light: {0} lux'.format(ambient_lux))
35+
print("Ambient light: {0} lux".format(ambient_lux))
3636
time.sleep(1.0)

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-vcnl4010',
22-
22+
name="adafruit-circuitpython-vcnl4010",
2323
use_scm_version=True,
24-
setup_requires=['setuptools_scm'],
25-
26-
description='CircuitPython library for VCNL4010 proximity and light sensor.',
24+
setup_requires=["setuptools_scm"],
25+
description="CircuitPython library for VCNL4010 proximity and light 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_VCNL4010',
32-
29+
url="https://github.com/adafruit/Adafruit_CircuitPython_VCNL4010",
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 vcnl4010 proximity light sensor breakout hardware micropython circuitpython',
56-
48+
keywords="adafruit vcnl4010 proximity light sensor breakout 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_vcnl4010'],
51+
py_modules=["adafruit_vcnl4010"],
6052
)

0 commit comments

Comments
 (0)