Skip to content

Commit eb28ad5

Browse files
committed
Apply black formatting
Use black to autoformat the code, so when making changes you don't have to worry about white space etc, and can just use black. Integrate into tox and the ci lint workflow for validation
1 parent 6661ad1 commit eb28ad5

38 files changed

+1115
-800
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ jobs:
2424
- name: Tests
2525
run: |
2626
pip install tox
27-
tox
27+
tox -epy3
2828
- name: Lint
2929
run: |
3030
pip install tox
31-
tox -eisort
31+
tox -eisort,black

docs/conf.py

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -29,42 +29,42 @@
2929
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3030
# ones.
3131
extensions = [
32-
'sphinx.ext.autodoc',
33-
'sphinx.ext.doctest',
34-
'sphinx.ext.todo',
35-
'sphinx.ext.coverage',
36-
'sphinx.ext.mathjax',
37-
'sphinx.ext.ifconfig',
38-
'sphinx.ext.viewcode',
32+
"sphinx.ext.autodoc",
33+
"sphinx.ext.doctest",
34+
"sphinx.ext.todo",
35+
"sphinx.ext.coverage",
36+
"sphinx.ext.mathjax",
37+
"sphinx.ext.ifconfig",
38+
"sphinx.ext.viewcode",
3939
]
4040

4141
# Add any paths that contain templates here, relative to this directory.
42-
templates_path = ['_templates']
42+
templates_path = ["_templates"]
4343

4444
# The suffix(es) of source filenames.
4545
# You can specify multiple suffix as a list of string:
4646
# source_suffix = ['.rst', '.md']
47-
source_suffix = '.rst'
47+
source_suffix = ".rst"
4848

4949
# The encoding of source files.
5050
# source_encoding = 'utf-8-sig'
5151

5252
# The master toctree document.
53-
master_doc = 'index'
53+
master_doc = "index"
5454

5555
# General information about the project.
56-
project = u'slackminion'
57-
copyright = u'2020 Pinterest, Inc.'
58-
author = u'Pinterest, Inc.'
56+
project = "slackminion"
57+
copyright = "2020 Pinterest, Inc."
58+
author = "Pinterest, Inc."
5959

6060
# The version info for the project you're documenting, acts as replacement for
6161
# |version| and |release|, also used in various other places throughout the
6262
# built documents.
6363
#
6464
# The short X.Y version.
65-
version = u'0'
65+
version = "0"
6666
# The full version, including alpha/beta/rc tags.
67-
release = u'0'
67+
release = "0"
6868

6969
# The language for content autogenerated by Sphinx. Refer to documentation
7070
# for a list of supported languages.
@@ -82,7 +82,7 @@
8282
# List of patterns, relative to source directory, that match files and
8383
# directories to ignore when looking for source files.
8484
# This patterns also effect to html_static_path and html_extra_path
85-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
85+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
8686

8787
# The reST default role (used for this markup: `text`) to use for all
8888
# documents.
@@ -100,7 +100,7 @@
100100
# show_authors = False
101101

102102
# The name of the Pygments (syntax highlighting) style to use.
103-
pygments_style = 'sphinx'
103+
pygments_style = "sphinx"
104104

105105
# A list of ignored prefixes for module index sorting.
106106
# modindex_common_prefix = []
@@ -144,7 +144,7 @@
144144
# Add any paths that contain custom static files (such as style sheets) here,
145145
# relative to this directory. They are copied after the builtin static files,
146146
# so a file named "default.css" will overwrite the builtin "default.css".
147-
html_static_path = ['_static']
147+
html_static_path = ["_static"]
148148

149149
# Add any extra paths that contain custom files (such as robots.txt or
150150
# .htaccess) here, relative to this directory. These files are copied
@@ -209,20 +209,17 @@
209209
# html_search_scorer = 'scorer.js'
210210

211211
# Output file base name for HTML help builder.
212-
htmlhelp_basename = 'slackminiondoc'
212+
htmlhelp_basename = "slackminiondoc"
213213

214214
# -- Options for LaTeX output ---------------------------------------------
215215

216216
latex_elements = {
217217
# The paper size ('letterpaper' or 'a4paper').
218218
# 'papersize': 'letterpaper',
219-
220219
# The font size ('10pt', '11pt' or '12pt').
221220
# 'pointsize': '10pt',
222-
223221
# Additional stuff for the LaTeX preamble.
224222
# 'preamble': '',
225-
226223
# Latex figure (float) alignment
227224
# 'figure_align': 'htbp',
228225
}
@@ -231,8 +228,13 @@
231228
# (source start file, target name, title,
232229
# author, documentclass [howto, manual, or own class]).
233230
latex_documents = [
234-
(master_doc, 'slackminion.tex', u'slackminion Documentation',
235-
u'Nick King', 'manual'),
231+
(
232+
master_doc,
233+
"slackminion.tex",
234+
"slackminion Documentation",
235+
"Nick King",
236+
"manual",
237+
),
236238
]
237239

238240
# The name of an image file (relative to this directory) to place at the top of
@@ -260,10 +262,7 @@
260262

261263
# One entry per manual page. List of tuples
262264
# (source start file, name, description, authors, manual section).
263-
man_pages = [
264-
(master_doc, 'slackminion', u'slackminion Documentation',
265-
[author], 1)
266-
]
265+
man_pages = [(master_doc, "slackminion", "slackminion Documentation", [author], 1)]
267266

268267
# If true, show URL addresses after external links.
269268
# man_show_urls = False
@@ -275,9 +274,15 @@
275274
# (source start file, target name, title, author,
276275
# dir menu entry, description, category)
277276
texinfo_documents = [
278-
(master_doc, 'slackminion', u'slackminion Documentation',
279-
author, 'slackminion', 'One line description of project.',
280-
'Miscellaneous'),
277+
(
278+
master_doc,
279+
"slackminion",
280+
"slackminion Documentation",
281+
author,
282+
"slackminion",
283+
"One line description of project.",
284+
"Miscellaneous",
285+
),
281286
]
282287

283288
# Documents to append as an appendix to all manuals.

setup.py

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,38 @@
33
from slackminion.plugins.core import version
44

55
setup(
6-
name='slackminion',
7-
version=version,
8-
packages=find_packages(exclude=['test_plugins']),
9-
url='https://github.com/pinterest/slackminion',
10-
license='MIT',
11-
author='Pinterest, Inc.',
12-
author_email='',
13-
description='A python bot framework for slack',
14-
package_data={'slackminion': ['templates/*']},
15-
python_requires='>=3.7',
16-
install_requires=[
17-
'Flask>=1.1.1',
18-
'itsdangerous>=0.24',
19-
'Jinja2>=2.10',
20-
'MarkupSafe>=0.23',
21-
'PyYAML>=4.2b',
22-
'requests >=2.11, <3.0a0',
23-
'slack_sdk==3.13.0',
24-
'websocket-client >=0.35, <0.55.0',
25-
'Werkzeug>=0.10.4',
26-
'aiohttp==3.7.4.post0',
27-
],
28-
entry_points={
29-
'console_scripts': [
30-
'slackminion = slackminion.__main__:main',
31-
]
32-
},
33-
classifiers=[
34-
"Programming Language :: Python",
35-
"License :: OSI Approved :: MIT License",
36-
"Operating System :: OS Independent",
37-
"Development Status :: 2 - Pre-Alpha",
38-
"Topic :: Communications :: Chat",
6+
name="slackminion",
7+
version=version,
8+
packages=find_packages(exclude=["test_plugins"]),
9+
url="https://github.com/pinterest/slackminion",
10+
license="MIT",
11+
author="Pinterest, Inc.",
12+
author_email="",
13+
description="A python bot framework for slack",
14+
package_data={"slackminion": ["templates/*"]},
15+
python_requires=">=3.7",
16+
install_requires=[
17+
"Flask>=1.1.1",
18+
"itsdangerous>=0.24",
19+
"Jinja2>=2.10",
20+
"MarkupSafe>=0.23",
21+
"PyYAML>=4.2b",
22+
"requests >=2.11, <3.0a0",
23+
"slack_sdk==3.13.0",
24+
"websocket-client >=0.35, <0.55.0",
25+
"Werkzeug>=0.10.4",
26+
"aiohttp==3.7.4.post0",
27+
],
28+
entry_points={
29+
"console_scripts": [
30+
"slackminion = slackminion.__main__:main",
3931
]
32+
},
33+
classifiers=[
34+
"Programming Language :: Python",
35+
"License :: OSI Approved :: MIT License",
36+
"Operating System :: OS Independent",
37+
"Development Status :: 2 - Pre-Alpha",
38+
"Topic :: Communications :: Chat",
39+
],
4040
)

slackminion/__main__.py

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,22 @@ def sigterm_handler(signum, frame):
1414
bot.runnable = False
1515

1616
p = argparse.ArgumentParser()
17-
p.add_argument('--config', action='store', default='config.yaml',
18-
help='Specify a config file (default: config.yaml)')
19-
p.add_argument('--test', action='store_true', help='Load plugins and exit')
17+
p.add_argument(
18+
"--config",
19+
action="store",
20+
default="config.yaml",
21+
help="Specify a config file (default: config.yaml)",
22+
)
23+
p.add_argument("--test", action="store_true", help="Load plugins and exit")
2024
args = p.parse_args()
2125

22-
with open(args.config, 'rb') as f:
26+
with open(args.config, "rb") as f:
2327
config = yaml.load(f, Loader=yaml.SafeLoader)
2428

25-
level = logging.DEBUG if config['debug'] else logging.INFO
26-
logging.basicConfig(level=level, format='%(asctime)s %(name)s %(levelname)s: %(message)s')
29+
level = logging.DEBUG if config["debug"] else logging.INFO
30+
logging.basicConfig(
31+
level=level, format="%(asctime)s %(name)s %(levelname)s: %(message)s"
32+
)
2733

2834
bot = Bot(config, args.test)
2935
bot.start()
@@ -39,25 +45,33 @@ def sigterm_handler(signum, frame):
3945
output.append("Plugins Loaded")
4046
for p in bot.plugin_manager.plugins:
4147
context = {
42-
'name': type(p).__name__,
43-
'version': '-'.join([p._version, p._commit]),
44-
'load_time': metrics['load_times'][type(p).__name__]
48+
"name": type(p).__name__,
49+
"version": "-".join([p._version, p._commit]),
50+
"load_time": metrics["load_times"][type(p).__name__],
4551
}
46-
output.append("{name:<30} {version:<20} {load_time:>7.03f} ms".format(**context))
47-
if len(metrics['plugins_failed']) > 0:
52+
output.append(
53+
"{name:<30} {version:<20} {load_time:>7.03f} ms".format(**context)
54+
)
55+
if len(metrics["plugins_failed"]) > 0:
4856
output.append("")
4957
output.append("Plugins failed to load")
50-
for p in metrics['plugins_failed']:
58+
for p in metrics["plugins_failed"]:
5159
output.append(p)
5260
output.append("")
53-
output.append("Bot startup time: %.03f ms" % bot.metrics['startup_time'])
54-
output.append("Plugins: %d total, %d loaded, %d failed" % (
55-
metrics['plugins_total'], metrics['plugins_loaded'], len(metrics['plugins_failed'])))
56-
if metrics['plugins_total'] != metrics['plugins_loaded']:
61+
output.append("Bot startup time: %.03f ms" % bot.metrics["startup_time"])
62+
output.append(
63+
"Plugins: %d total, %d loaded, %d failed"
64+
% (
65+
metrics["plugins_total"],
66+
metrics["plugins_loaded"],
67+
len(metrics["plugins_failed"]),
68+
)
69+
)
70+
if metrics["plugins_total"] != metrics["plugins_loaded"]:
5771
output.append("")
5872
output.append("=== Bot Failed Startup Tests ===")
5973
test_passed = False
60-
logging.getLogger().info('\n'.join(output))
74+
logging.getLogger().info("\n".join(output))
6175

6276
if not test_passed:
6377
sys.exit(1)

0 commit comments

Comments
 (0)