Skip to content

Commit 5670911

Browse files
committed
Fix PEP8 issues and format consistently
Resolves PEP8 requirement #211 - Format using black - Format using ruff - Manually fix remaining flake8 errors
1 parent b2c3280 commit 5670911

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+2367
-1575
lines changed

.flake8

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ ignore =
1111
# W503 line break before binary operator
1212
W503,
1313
exclude =
14+
__pycache__,
1415
.git/,
1516
.idea/,
1617
.venv/,
1718
.vscode/,
18-
__pycache__,
1919
dist/,
2020
docs/conf.py,
21+
generator/templates/,
2122
venv/,
2223
versioneer.py,
2324
webexteamssdk/_version.py,

.ruff.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
line-length = 79
2+
3+
# B: flake8-bugbear
4+
# Q: flake8-quotes
5+
extend-select = [ "B", "Q", "W" ]
6+
7+
ignore-init-module-imports = true
8+
9+
extend-exclude = [
10+
"versioneer.py",
11+
"webexteamssdk/_version.py",
12+
"generator/**",
13+
]
14+
15+
[lint]
16+
ignore = [
17+
# E402 module level import not at top of file
18+
"E402",
19+
# F401 'builtins.*' imported but unused
20+
"F401",
21+
# F403 'from builtins import *' used; unable to detect undefined names
22+
"F403",
23+
# F405 'unicode' may be undefined, or defined from star imports: builtins
24+
"F405",
25+
]

docs/conf.py

Lines changed: 57 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -4,71 +4,69 @@
44
import sys
55

66

7-
sys.path.insert(0, os.path.abspath('..'))
7+
sys.path.insert(0, os.path.abspath(".."))
88

99

1010
from webexteamssdk._version import get_versions
1111

1212

13-
project = u'webexteamssdk'
14-
copyright = u'Copyright (c) 2016-2020 Cisco and/or its affiliates.'
15-
author = u'Chris Lunsford'
16-
version = get_versions()['version']
17-
release = get_versions()['version']
13+
project = "webexteamssdk"
14+
copyright = "Copyright (c) 2016-2020 Cisco and/or its affiliates."
15+
author = "Chris Lunsford"
16+
version = get_versions()["version"]
17+
release = get_versions()["version"]
1818
language = None
1919

2020

2121
extensions = [
22-
'sphinx.ext.autodoc',
23-
'sphinx.ext.doctest',
24-
'sphinx.ext.intersphinx',
25-
'sphinx.ext.todo',
26-
'sphinx.ext.coverage',
27-
'sphinx.ext.viewcode',
28-
'sphinx.ext.napoleon',
22+
"sphinx.ext.autodoc",
23+
"sphinx.ext.doctest",
24+
"sphinx.ext.intersphinx",
25+
"sphinx.ext.todo",
26+
"sphinx.ext.coverage",
27+
"sphinx.ext.viewcode",
28+
"sphinx.ext.napoleon",
2929
]
3030

3131

32-
master_doc = 'index'
33-
source_suffix = '.rst'
34-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
35-
templates_path = ['_templates']
36-
pygments_style = 'sphinx'
32+
master_doc = "index"
33+
source_suffix = ".rst"
34+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
35+
templates_path = ["_templates"]
36+
pygments_style = "sphinx"
3737

3838

3939
add_module_names = False
40-
autodoc_member_order = 'bysource'
40+
autodoc_member_order = "bysource"
4141
# autodoc_default_flags = ['members', 'undoc-members']
4242
autodoc_default_options = {
43-
'members': None,
44-
'undoc-members': None,
43+
"members": None,
44+
"undoc-members": None,
4545
}
4646

4747

4848
todo_include_todos = True
4949

5050

51-
5251
# -- Options for HTML output ----------------------------------------------
5352

5453
# The theme to use for HTML and HTML Help pages. See the documentation for
5554
# a list of builtin themes.
5655
#
57-
#html_theme = 'alabaster'
58-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
56+
# html_theme = 'alabaster'
57+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
5958

6059
if not on_rtd:
6160
import sphinx_rtd_theme
62-
html_theme = 'sphinx_rtd_theme'
61+
62+
html_theme = "sphinx_rtd_theme"
6363
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
6464

6565
# Theme options are theme-specific and customize the look and feel of a theme
6666
# further. For a list of options available for each theme, see the
6767
# documentation.
6868
#
69-
html_theme_options = {
70-
'collapse_navigation': False
71-
}
69+
html_theme_options = {"collapse_navigation": False}
7270

7371
# Add any paths that contain custom themes here, relative to this directory.
7472
# html_theme_path = []
@@ -176,36 +174,37 @@
176174
# html_search_scorer = 'scorer.js'
177175

178176
# Output file base name for HTML help builder.
179-
htmlhelp_basename = 'webexteamssdkdoc'
180-
177+
htmlhelp_basename = "webexteamssdkdoc"
181178

182179

183180
# -- Options for LaTeX output ---------------------------------------------
184181

185182
latex_elements = {
186-
# The paper size ('letterpaper' or 'a4paper').
187-
#
188-
# 'papersize': 'letterpaper',
189-
190-
# The font size ('10pt', '11pt' or '12pt').
191-
#
192-
# 'pointsize': '10pt',
193-
194-
# Additional stuff for the LaTeX preamble.
195-
#
196-
# 'preamble': '',
197-
198-
# Latex figure (float) alignment
199-
#
200-
# 'figure_align': 'htbp',
183+
# The paper size ('letterpaper' or 'a4paper').
184+
#
185+
# 'papersize': 'letterpaper',
186+
# The font size ('10pt', '11pt' or '12pt').
187+
#
188+
# 'pointsize': '10pt',
189+
# Additional stuff for the LaTeX preamble.
190+
#
191+
# 'preamble': '',
192+
# Latex figure (float) alignment
193+
#
194+
# 'figure_align': 'htbp',
201195
}
202196

203197
# Grouping the document tree into LaTeX files. List of tuples
204198
# (source start file, target name, title,
205199
# author, documentclass [howto, manual, or own class]).
206200
latex_documents = [
207-
(master_doc, 'webexteamssdk.tex', u'webexteamssdk Documentation',
208-
u'Chris Lunsford', 'manual'),
201+
(
202+
master_doc,
203+
"webexteamssdk.tex",
204+
"webexteamssdk Documentation",
205+
"Chris Lunsford",
206+
"manual",
207+
),
209208
]
210209

211210
# The name of an image file (relative to this directory) to place at the top of
@@ -241,31 +240,34 @@
241240
# latex_domain_indices = True
242241

243242

244-
245243
# -- Options for manual page output ---------------------------------------
246244

247245
# One entry per manual page. List of tuples
248246
# (source start file, name, description, authors, manual section).
249247
man_pages = [
250-
(master_doc, 'webexteamssdk', u'webexteamssdk Documentation',
251-
[author], 1)
248+
(master_doc, "webexteamssdk", "webexteamssdk Documentation", [author], 1)
252249
]
253250

254251
# If true, show URL addresses after external links.
255252
#
256253
# man_show_urls = False
257254

258255

259-
260256
# -- Options for Texinfo output -------------------------------------------
261257

262258
# Grouping the document tree into Texinfo files. List of tuples
263259
# (source start file, target name, title, author,
264260
# dir menu entry, description, category)
265261
texinfo_documents = [
266-
(master_doc, 'webexteamssdk', u'webexteamssdk Documentation',
267-
author, 'webexteamssdk', 'One line description of project.',
268-
'Miscellaneous'),
262+
(
263+
master_doc,
264+
"webexteamssdk",
265+
"webexteamssdk Documentation",
266+
author,
267+
"webexteamssdk",
268+
"One line description of project.",
269+
"Miscellaneous",
270+
),
269271
]
270272

271273
# Documents to append as an appendix to all manuals.
@@ -286,4 +288,4 @@
286288

287289

288290
# Example configuration for intersphinx: refer to the Python standard library.
289-
intersphinx_mapping = {'https://docs.python.org/': None}
291+
intersphinx_mapping = {"https://docs.python.org/": None}

examples/bot-example-flask.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868

6969

7070
# Module constants
71-
CAT_FACTS_URL = 'https://catfact.ninja/fact'
71+
CAT_FACTS_URL = "https://catfact.ninja/fact"
7272

7373

7474
# Initialize the environment
@@ -89,16 +89,16 @@ def get_catfact():
8989
response = requests.get(CAT_FACTS_URL, verify=False)
9090
response.raise_for_status()
9191
json_data = response.json()
92-
return json_data['fact']
92+
return json_data["fact"]
9393

9494

9595
# Core bot functionality
9696
# Your Webex Teams webhook should point to http://<serverip>:5000/events
97-
@flask_app.route('/events', methods=['GET', 'POST'])
97+
@flask_app.route("/events", methods=["GET", "POST"])
9898
def webex_teams_webhook_events():
9999
"""Processes incoming requests to the '/events' URI."""
100-
if request.method == 'GET':
101-
return ("""<!DOCTYPE html>
100+
if request.method == "GET":
101+
return """<!DOCTYPE html>
102102
<html lang="en">
103103
<head>
104104
<meta charset="UTF-8">
@@ -114,8 +114,10 @@ def webex_teams_webhook_events():
114114
<blockquote>{}</blockquote>
115115
</body>
116116
</html>
117-
""".format(get_catfact()))
118-
elif request.method == 'POST':
117+
""".format(
118+
get_catfact()
119+
)
120+
elif request.method == "POST":
119121
"""Respond to inbound webhook JSON HTTP POST from Webex Teams."""
120122

121123
# Get the POST data sent from Webex Teams
@@ -144,7 +146,7 @@ def webex_teams_webhook_events():
144146
me = api.people.me()
145147
if message.personId == me.id:
146148
# Message was sent by me (bot); do not respond.
147-
return 'OK'
149+
return "OK"
148150

149151
else:
150152
# Message was sent by someone else; parse message and respond.
@@ -155,9 +157,9 @@ def webex_teams_webhook_events():
155157
print("SENDING CAT FACT '{}'".format(cat_fact))
156158
# Post the fact to the room where the request was received
157159
api.messages.create(room.id, text=cat_fact)
158-
return 'OK'
160+
return "OK"
159161

160162

161-
if __name__ == '__main__':
163+
if __name__ == "__main__":
162164
# Start the Flask web server
163-
flask_app.run(host='0.0.0.0', port=5000)
165+
flask_app.run(host="0.0.0.0", port=5000)

examples/bot-example-webpy.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@
6868

6969

7070
# Module constants
71-
CAT_FACTS_URL = 'https://catfact.ninja/fact'
71+
CAT_FACTS_URL = "https://catfact.ninja/fact"
7272

7373

7474
# Global variables
7575
# Your Webex Teams webhook should point to http://<serverip>:8080/events
76-
urls = ('/events', 'webhook')
76+
urls = ("/events", "webhook")
7777
# Create the web application instance
7878
app = web.application(urls, globals())
7979
# Create the Webex Teams API connection object
@@ -90,7 +90,7 @@ def get_catfact():
9090
response = requests.get(CAT_FACTS_URL, verify=False)
9191
response.raise_for_status()
9292
json_data = response.json()
93-
return json_data['fact']
93+
return json_data["fact"]
9494

9595

9696
class webhook(object):
@@ -120,7 +120,7 @@ def POST(self):
120120
me = api.people.me()
121121
if message.personId == me.id:
122122
# Message was sent by me (bot); do not respond.
123-
return 'OK'
123+
return "OK"
124124
else:
125125
# Message was sent by someone else; parse message and respond.
126126
if "/CAT" in message.text:
@@ -130,9 +130,9 @@ def POST(self):
130130
print("SENDING CAT FACT '{}'".format(cat_fact))
131131
# Post the fact to the room where the request was received
132132
api.messages.create(room.id, text=cat_fact)
133-
return 'OK'
133+
return "OK"
134134

135135

136-
if __name__ == '__main__':
136+
if __name__ == "__main__":
137137
# Start the web.py web server
138138
app.run()

0 commit comments

Comments
 (0)