Skip to content

Commit d4bb20c

Browse files
committed
Add black code linter
1 parent 99c822e commit d4bb20c

35 files changed

+823
-663
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
name: CI
22

3-
on: [pull_request]
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
48

59
jobs:
610

11+
black:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/setup-python@v1
15+
- uses: actions/checkout@v2
16+
- run: python -m pip install black
17+
- run: black --check --diff .
18+
719
docs:
820
runs-on: ubuntu-latest
921
steps:
@@ -64,6 +76,8 @@ jobs:
6476
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
6577

6678
extras:
79+
needs:
80+
- dist
6781
runs-on: ubuntu-latest
6882
strategy:
6983
matrix:

.github/workflows/release.yml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
name: PyPi Release
1+
name: Release
22

3-
on: [release]
3+
on:
4+
release:
5+
types: [published]
46

57
jobs:
6-
build:
7-
8+
PyPI:
89
runs-on: ubuntu-latest
910
steps:
10-
- uses: actions/checkout@v1
11-
- uses: actions/setup-python@v1
12-
- name: Install Python dependencies
13-
run: python -m pip install --upgrade pip setuptools wheel twine
14-
- name: Build dist packages
15-
run: python setup.py sdist bdist_wheel
16-
- name: Upload packages
17-
run: python -m twine upload dist/*
18-
env:
19-
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
20-
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
11+
- uses: actions/setup-python@v2
12+
- uses: actions/checkout@v2
13+
- name: Install Python dependencies
14+
run: python -m pip install --upgrade pip setuptools wheel twine
15+
- name: Build dist packages
16+
run: python setup.py sdist bdist_wheel
17+
- name: Upload packages
18+
run: python -m twine upload dist/*
19+
env:
20+
TWINE_USERNAME: __token__
21+
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}

docs/conf.py

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,74 +6,82 @@
66
import django
77

88
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.testapp.settings")
9-
sys.path.insert(0, os.path.abspath('..'))
9+
sys.path.insert(0, os.path.abspath(".."))
1010
django.setup()
1111

1212
extensions = [
13-
'sphinx.ext.autodoc',
14-
'sphinx.ext.napoleon',
15-
'sphinx.ext.inheritance_diagram',
16-
'sphinx.ext.intersphinx',
17-
'sphinx.ext.githubpages',
18-
'sphinx.ext.linkcode',
13+
"sphinx.ext.autodoc",
14+
"sphinx.ext.napoleon",
15+
"sphinx.ext.inheritance_diagram",
16+
"sphinx.ext.intersphinx",
17+
"sphinx.ext.githubpages",
18+
"sphinx.ext.linkcode",
1919
]
2020

2121
try:
2222
import sphinxcontrib.spelling # noqa
2323
except ImportError:
2424
pass
2525
else:
26-
extensions.append('sphinxcontrib.spelling')
26+
extensions.append("sphinxcontrib.spelling")
2727

2828

2929
def linkcode_resolve(domain, info):
3030
"""Link source code to GitHub."""
31-
project = 'joeflow'
32-
github_user = 'codingjoe'
33-
head = 'master'
31+
project = "joeflow"
32+
github_user = "codingjoe"
33+
head = "master"
3434

35-
if domain != 'py' or not info['module']:
35+
if domain != "py" or not info["module"]:
3636
return None
37-
filename = info['module'].replace('.', '/')
38-
mod = importlib.import_module(info['module'])
37+
filename = info["module"].replace(".", "/")
38+
mod = importlib.import_module(info["module"])
3939
basename = os.path.splitext(mod.__file__)[0]
40-
if basename.endswith('__init__'):
41-
filename += '/__init__'
40+
if basename.endswith("__init__"):
41+
filename += "/__init__"
4242
item = mod
43-
lineno = ''
43+
lineno = ""
4444

45-
for piece in info['fullname'].split('.'):
45+
for piece in info["fullname"].split("."):
4646
try:
4747
item = getattr(item, piece)
4848
except AttributeError:
4949
pass
5050
try:
5151
lines, first_line = inspect.getsourcelines(item)
52-
lineno = '#L%d-L%s' % (first_line, first_line + len(lines) - 1)
52+
lineno = "#L%d-L%s" % (first_line, first_line + len(lines) - 1)
5353
except (TypeError, IOError):
5454
pass
55-
return ("https://github.com/%s/%s/blob/%s/%s.py%s" %
56-
(github_user, project, head, filename, lineno))
55+
return "https://github.com/%s/%s/blob/%s/%s.py%s" % (
56+
github_user,
57+
project,
58+
head,
59+
filename,
60+
lineno,
61+
)
5762

5863

5964
# The master toctree document.
60-
master_doc = 'index'
61-
project = 'Joeflow'
65+
master_doc = "index"
66+
project = "Joeflow"
6267

63-
html_theme = 'alabaster'
68+
html_theme = "alabaster"
6469

6570
intersphinx_mapping = {
66-
'python': ('https://docs.python.org/3', None),
67-
'django': ('https://docs.djangoproject.com/en/stable/',
68-
'https://docs.djangoproject.com/en/stable/_objects/'),
69-
'celery': ('https://celery.readthedocs.io/en/stable/', None),
70-
'graphviz': ('https://graphviz.readthedocs.io/en/stable/', None),
71+
"python": ("https://docs.python.org/3", None),
72+
"django": (
73+
"https://docs.djangoproject.com/en/stable/",
74+
"https://docs.djangoproject.com/en/stable/_objects/",
75+
),
76+
"celery": ("https://celery.readthedocs.io/en/stable/", None),
77+
"graphviz": ("https://graphviz.readthedocs.io/en/stable/", None),
7178
}
7279

73-
spelling_word_list_filename = 'spelling_wordlist.txt'
80+
spelling_word_list_filename = "spelling_wordlist.txt"
7481
spelling_show_suggestions = True
7582

76-
graphviz_output_format = 'svg'
83+
graphviz_output_format = "svg"
7784

78-
inheritance_graph_attrs = dict(rankdir="TB", size='"6.0, 8.0"',
79-
fontsize=14, ratio='compress')
85+
inheritance_graph_attrs = dict(
86+
rankdir="TB", size='"6.0, 8.0"', fontsize=14, ratio="compress"
87+
)

joeflow/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""The lean workflow automation framework for machines with heart."""
2-
default_app_config = 'joeflow.apps.JoeflowConfig'
2+
default_app_config = "joeflow.apps.JoeflowConfig"

joeflow/admin.py

Lines changed: 62 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -6,121 +6,125 @@
66
from . import models
77
from .contrib.reversion import VersionAdmin
88

9-
__all__ = (
10-
'ProcessAdmin',
11-
)
9+
__all__ = ("ProcessAdmin",)
1210

1311

1412
def rerun(modeladmin, request, queryset):
1513
succeeded = queryset.succeeded().count()
1614
if succeeded:
17-
messages.warning(request, "Only failed tasks can be retried. %s tasks have been skipped" % succeeded)
15+
messages.warning(
16+
request,
17+
"Only failed tasks can be retried. %s tasks have been skipped" % succeeded,
18+
)
1819
counter = 0
1920
for obj in queryset.not_succeeded().iterator():
2021
obj.enqueue()
2122
counter += 1
2223
messages.success(request, "%s tasks have been successfully queued" % counter)
2324

2425

25-
rerun.short_description = t('Rerun selected tasks')
26-
rerun.allowed_permissions = ('rerun',)
26+
rerun.short_description = t("Rerun selected tasks")
27+
rerun.allowed_permissions = ("rerun",)
2728

2829

2930
def cancel(modeladmin, request, queryset):
3031
not_scheduled = queryset.not_scheduled().count()
3132
if not_scheduled:
32-
messages.warning(request, "Only scheduled tasks can be canceled. %s tasks have been skipped" % not_scheduled)
33+
messages.warning(
34+
request,
35+
"Only scheduled tasks can be canceled. %s tasks have been skipped"
36+
% not_scheduled,
37+
)
3338
queryset.scheduled().cancel(request.user)
3439
messages.success(request, "Tasks have been successfully canceled")
3540

3641

37-
cancel.short_description = t('Cancel selected tasks')
38-
cancel.allowed_permissions = ('cancel',)
42+
cancel.short_description = t("Cancel selected tasks")
43+
cancel.allowed_permissions = ("cancel",)
3944

4045

4146
@admin.register(models.Task)
4247
class TaskAdmin(VersionAdmin):
43-
4448
def has_rerun_permission(self, request):
4549
opts = self.opts
46-
codename = get_permission_codename('rerun', opts)
47-
return request.user.has_perm('%s.%s' % (opts.app_label, codename))
50+
codename = get_permission_codename("rerun", opts)
51+
return request.user.has_perm("%s.%s" % (opts.app_label, codename))
4852

4953
def has_cancel_permission(self, request):
5054
opts = self.opts
51-
codename = get_permission_codename('cancel', opts)
52-
return request.user.has_perm('%s.%s' % (opts.app_label, codename))
55+
codename = get_permission_codename("cancel", opts)
56+
return request.user.has_perm("%s.%s" % (opts.app_label, codename))
5357

5458
def pretty_stacktrace(self, obj):
5559
return format_html('<pre class="readonly collapse">{}<pre>', obj.stacktrace)
5660

57-
pretty_stacktrace.short_description = t('Traceback')
61+
pretty_stacktrace.short_description = t("Traceback")
5862

5963
def child_tasks(self, obj):
6064
return ", ".join(str(task) for task in obj.child_task_set.all().iterator())
6165

62-
child_tasks.short_description = t('Child tasks')
66+
child_tasks.short_description = t("Child tasks")
6367

6468
actions = (rerun, cancel)
6569

6670
list_display = (
67-
'name',
68-
'status',
69-
'type',
70-
'content_type',
71-
'completed',
72-
'modified',
73-
'created',
71+
"name",
72+
"status",
73+
"type",
74+
"content_type",
75+
"completed",
76+
"modified",
77+
"created",
7478
)
7579

7680
readonly_fields = (
77-
'process',
78-
'name',
79-
'type',
80-
'parent_task_set',
81-
'child_tasks',
82-
'completed',
83-
'created',
84-
'modified',
85-
'exception',
86-
'pretty_stacktrace',
81+
"process",
82+
"name",
83+
"type",
84+
"parent_task_set",
85+
"child_tasks",
86+
"completed",
87+
"created",
88+
"modified",
89+
"exception",
90+
"pretty_stacktrace",
8791
)
8892

8993
list_filter = (
90-
'status',
91-
'type',
92-
'content_type',
93-
'completed',
94-
'created',
94+
"status",
95+
"type",
96+
"content_type",
97+
"completed",
98+
"created",
9599
)
96100

97101
fieldsets = (
98-
(None, {
99-
'fields': (
100-
'process',
101-
'name',
102-
'parent_task_set',
103-
'child_tasks',
104-
'completed',
105-
'modified',
106-
'created',
107-
'exception'
108-
),
109-
}),
110-
(t('Traceback'), {
111-
'classes': ('collapse',),
112-
'fields': ('pretty_stacktrace',),
113-
}),
102+
(
103+
None,
104+
{
105+
"fields": (
106+
"process",
107+
"name",
108+
"parent_task_set",
109+
"child_tasks",
110+
"completed",
111+
"modified",
112+
"created",
113+
"exception",
114+
),
115+
},
116+
),
117+
(t("Traceback"), {"classes": ("collapse",), "fields": ("pretty_stacktrace",)}),
114118
)
115119

116120

117121
class ProcessAdmin(VersionAdmin):
118122
readonly_fields = (
119-
'modified',
120-
'created',
123+
"modified",
124+
"created",
121125
)
122126

123127
list_filter = (
124-
'modified',
125-
'created',
128+
"modified",
129+
"created",
126130
)

joeflow/apps.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33

44

55
class JoeflowConfig(AppConfig):
6-
name = 'joeflow'
7-
verbose_name = t('Joeflow')
6+
name = "joeflow"
7+
verbose_name = t("Joeflow")
88

99
def ready(self):
1010
from .contrib.reversion import register_processes
11+
1112
register_processes()

0 commit comments

Comments
 (0)