Skip to content

Commit bf7b4b6

Browse files
committed
Ran black, updated to pylint 2.x
1 parent f49f34e commit bf7b4b6

File tree

6 files changed

+126
-126
lines changed

6 files changed

+126
-126
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,13 @@ jobs:
3434
with:
3535
repository: adafruit/actions-ci-circuitpython-libs
3636
path: actions-ci
37-
- name: Install deps
37+
- name: Install dependencies
38+
# (e.g. - apt-get: gettext, etc; pip: circuitpython-build-tools, requirements.txt; etc.)
3839
run: |
3940
source actions-ci/install.sh
41+
- name: Pip install pylint, black, & Sphinx
42+
run: |
43+
pip install --force-reinstall pylint==1.9.2 black==19.10b0 Sphinx sphinx-rtd-theme
4044
- name: Library version
4145
run: git describe --dirty --always --tags
4246
- name: PyLint

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ confidence=
5252
# no Warning level messages displayed, use"--disable=all --enable=classes
5353
# --disable=W"
5454
# disable=import-error,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call
55-
disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error
55+
disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error,bad-continuation
5656

5757
# Enable the message, report, category or checker with the given id(s). You can
5858
# either give multiple identifier separated by comma (,) or put this option

adafruit_lifx.py

Lines changed: 27 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -43,50 +43,52 @@
4343
__version__ = "0.0.0-auto.0"
4444
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_lifx.git"
4545

46-
LIFX_URL = 'https://api.lifx.com/v1/lights/'
46+
LIFX_URL = "https://api.lifx.com/v1/lights/"
47+
4748

4849
class LIFX:
4950
"""
5051
HTTP Interface for interacting with the LIFX API
5152
"""
53+
5254
def __init__(self, wifi_manager, lifx_token):
5355
"""
5456
Creates an instance of the LIFX HTTP API client.
5557
:param wifi_manager wifi_manager: WiFiManager from ESPSPI_WiFiManager/ESPAT_WiFiManager
5658
:param str lifx_token: LIFX API token (https://api.developer.lifx.com/docs/authentication)
5759
"""
5860
wifi_type = str(type(wifi_manager))
59-
if ('ESPSPI_WiFiManager' in wifi_type or 'ESPAT_WiFiManager' in wifi_type):
61+
if "ESPSPI_WiFiManager" in wifi_type or "ESPAT_WiFiManager" in wifi_type:
6062
self._wifi = wifi_manager
6163
else:
6264
raise TypeError("This library requires a WiFiManager object.")
6365
self._lifx_token = lifx_token
64-
self._auth_header = {"Authorization": "Bearer %s" % self._lifx_token,}
66+
self._auth_header = {
67+
"Authorization": "Bearer %s" % self._lifx_token,
68+
}
6569

6670
@staticmethod
6771
def _parse_resp(response):
6872
"""Parses and returns the JSON response returned
6973
from the LIFX HTTP API.
7074
"""
7175
if response.status_code == 422:
72-
raise Exception('Error: light(s) could not be toggled: '+ response['error'])
76+
raise Exception(
77+
"Error: light(s) could not be toggled: " + response["error"]
78+
)
7379
try:
74-
for res in response.json()['results']:
75-
return res['status']
80+
for res in response.json()["results"]:
81+
return res["status"]
7682
except KeyError:
77-
raise KeyError(response.json()['error'])
83+
raise KeyError(response.json()["error"])
7884

7985
# HTTP Requests
8086
def _post(self, path, data):
8187
"""POST data to the LIFX API.
8288
:param str path: Formatted LIFX API URL
8389
:param json data: JSON data to POST to the LIFX API.
8490
"""
85-
response = self._wifi.post(
86-
path,
87-
json=data,
88-
headers=self._auth_header
89-
)
91+
response = self._wifi.post(path, json=data, headers=self._auth_header)
9092
response = self._parse_resp(response)
9193
return response
9294

@@ -95,11 +97,7 @@ def _put(self, path, data):
9597
:param str path: Formatted LIFX API URL
9698
:param json data: JSON data to PUT to the LIFX API.
9799
"""
98-
response = self._wifi.put(
99-
path,
100-
json=data,
101-
headers=self._auth_header
102-
)
100+
response = self._wifi.put(path, json=data, headers=self._auth_header)
103101
response = self._parse_resp(response)
104102
return response
105103

@@ -108,11 +106,7 @@ def _get(self, path, data):
108106
:param str path: Formatted LIFX API URL
109107
:param json data: JSON data to GET from the LIFX API.
110108
"""
111-
response = self._wifi.get(
112-
path,
113-
json=data,
114-
headers=self._auth_header
115-
)
109+
response = self._wifi.get(path, json=data, headers=self._auth_header)
116110
return response.json()
117111

118112
def toggle_light(self, selector, all_lights=False, duration=0):
@@ -122,50 +116,45 @@ def toggle_light(self, selector, all_lights=False, duration=0):
122116
:param double duration: Time (in seconds) to spend performing a toggle. Defaults to 0.
123117
"""
124118
if all_lights:
125-
selector = 'all'
126-
data = {'duration':duration}
127-
return self._post(LIFX_URL+selector+'/toggle', data)
119+
selector = "all"
120+
data = {"duration": duration}
121+
return self._post(LIFX_URL + selector + "/toggle", data)
128122

129123
def move_effect(self, selector, move_direction, period, power_on):
130124
"""Performs a linear move effect on a light, or lights.
131125
:param str move_direction: Move direction, forward or backward.
132126
:param double period: Time in second per effect cycle.
133127
:param bool power_on: Turn on a light before performing the move.
134128
"""
135-
data = {'direction':move_direction,
136-
'period':period,
137-
'power_on':power_on}
138-
return self._post(LIFX_URL+selector+'/effects/move', data)
129+
data = {"direction": move_direction, "period": period, "power_on": power_on}
130+
return self._post(LIFX_URL + selector + "/effects/move", data)
139131

140132
def effects_off(self, selector, power_off=False):
141133
"""Turns off any running effects on the selected device.
142134
:param dict selector: Selector to control which lights are requested.
143135
:param bool power_off: If true, the devices will also be turned off.
144136
"""
145-
data = {'power_off', power_off}
146-
return self._post(LIFX_URL+selector+'/effects/off', data)
137+
data = {"power_off", power_off}
138+
return self._post(LIFX_URL + selector + "/effects/off", data)
147139

148140
def set_brightness(self, selector, brightness):
149141
"""Sets the state of the lights within the selector.
150142
:param dict selector: Selector to control which lights are requested.
151143
:param double brightness: Brightness level of the light, from 0.0 to 1.0.
152144
"""
153-
data = {'brightness':brightness}
154-
return self._put(LIFX_URL+selector+'/state', data)
145+
data = {"brightness": brightness}
146+
return self._put(LIFX_URL + selector + "/state", data)
155147

156148
def set_color(self, selector, **kwargs):
157149
"""Sets the state of the light's color within the selector.
158150
Valid arguments: https://api.developer.lifx.com/docs/set-state
159151
"""
160-
return self._put(LIFX_URL+selector+'/state', kwargs)
152+
return self._put(LIFX_URL + selector + "/state", kwargs)
161153

162154
def list_lights(self):
163155
"""Enumerates all the lights associated with the LIFX Cloud Account
164156
"""
165-
response = self._wifi.get(
166-
url=LIFX_URL+'all',
167-
headers=self._auth_header
168-
)
157+
response = self._wifi.get(url=LIFX_URL + "all", headers=self._auth_header)
169158
resp = response.json()
170159
response.close()
171160
return resp

docs/conf.py

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

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

2226
# Add any paths that contain templates here, relative to this directory.
23-
templates_path = ['_templates']
27+
templates_path = ["_templates"]
2428

25-
source_suffix = '.rst'
29+
source_suffix = ".rst"
2630

2731
# The master toctree document.
28-
master_doc = 'index'
32+
master_doc = "index"
2933

3034
# General information about the project.
31-
project = u'Adafruit LIFX Library'
32-
copyright = u'2019 Brent Rubell'
33-
author = u'Brent Rubell'
35+
project = "Adafruit LIFX Library"
36+
copyright = "2019 Brent Rubell"
37+
author = "Brent Rubell"
3438

3539
# The version info for the project you're documenting, acts as replacement for
3640
# |version| and |release|, also used in various other places throughout the
3741
# built documents.
3842
#
3943
# The short X.Y version.
40-
version = u'1.0'
44+
version = "1.0"
4145
# The full version, including alpha/beta/rc tags.
42-
release = u'1.0'
46+
release = "1.0"
4347

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

5660
# The reST default role (used for this markup: `text`) to use for all
5761
# documents.
@@ -63,7 +67,7 @@
6367
add_function_parentheses = True
6468

6569
# The name of the Pygments (syntax highlighting) style to use.
66-
pygments_style = 'sphinx'
70+
pygments_style = "sphinx"
6771

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

8387
if not on_rtd: # only import and set the theme if we're building docs locally
8488
try:
8589
import sphinx_rtd_theme
86-
html_theme = 'sphinx_rtd_theme'
87-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
90+
91+
html_theme = "sphinx_rtd_theme"
92+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
8893
except:
89-
html_theme = 'default'
90-
html_theme_path = ['.']
94+
html_theme = "default"
95+
html_theme_path = ["."]
9196
else:
92-
html_theme_path = ['.']
97+
html_theme_path = ["."]
9398

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

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

105110
# Output file base name for HTML help builder.
106-
htmlhelp_basename = 'AdafruitLifxLibrarydoc'
111+
htmlhelp_basename = "AdafruitLifxLibrarydoc"
107112

108113
# -- Options for LaTeX output ---------------------------------------------
109114

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

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

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

138145
# One entry per manual page. List of tuples
139146
# (source start file, name, description, authors, manual section).
140147
man_pages = [
141-
(master_doc, 'Adafruitlifxlibrary', u'Adafruit lifx Library Documentation',
142-
[author], 1)
148+
(
149+
master_doc,
150+
"Adafruitlifxlibrary",
151+
"Adafruit lifx Library Documentation",
152+
[author],
153+
1,
154+
)
143155
]
144156

145157
# -- Options for Texinfo output -------------------------------------------
@@ -148,7 +160,13 @@
148160
# (source start file, target name, title, author,
149161
# dir menu entry, description, category)
150162
texinfo_documents = [
151-
(master_doc, 'AdafruitlifxLibrary', u'Adafruit lifx Library Documentation',
152-
author, 'AdafruitlifxLibrary', 'One line description of project.',
153-
'Miscellaneous'),
163+
(
164+
master_doc,
165+
"AdafruitlifxLibrary",
166+
"Adafruit lifx Library Documentation",
167+
author,
168+
"AdafruitlifxLibrary",
169+
"One line description of project.",
170+
"Miscellaneous",
171+
),
154172
]

0 commit comments

Comments
 (0)