Skip to content

Commit 021abd5

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 941733a commit 021abd5

18 files changed

Lines changed: 84 additions & 58 deletions

File tree

‎joeflow/conf.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66

77
class JoeflowAppConfig(AppConf):
8-
"""List of available settings.
8+
"""
9+
List of available settings.
910
1011
To change the default values just set the setting in your settings file.
1112
"""

‎joeflow/contrib/reversion.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import joeflow.models
44

55
__all__ = (
6-
"register_workflows",
76
"RevisionMixin",
8-
"with_reversion",
97
"VersionAdmin",
8+
"register_workflows",
9+
"with_reversion",
1010
)
1111

1212

‎joeflow/management/commands/render_workflow_graph.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def handle(self, *args, **options):
4242
verbosity = options["verbosity"]
4343
file_format = options["format"]
4444
cleanup = options["cleanup"]
45-
directory = options.get("directory", None)
45+
directory = options.get("directory")
4646

4747
workflows = [
4848
joeflow.models.get_workflow(s) for s in workflows

‎joeflow/models.py‎

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
logger = logging.getLogger(__name__)
2525

2626
__all__ = (
27-
"Workflow",
2827
"Task",
28+
"Workflow",
2929
)
3030

3131

@@ -56,7 +56,8 @@ def __new__(mcs, name, bases, attrs):
5656

5757

5858
class Workflow(models.Model, metaclass=WorkflowBase):
59-
"""The `WorkflowState` object holds the state of a workflow instances.
59+
"""
60+
The `WorkflowState` object holds the state of a workflow instances.
6061
6162
It is represented by a Django Model. This way all workflow states
6263
are persisted in your database.
@@ -118,7 +119,8 @@ def get_nodes(cls):
118119

119120
@classmethod
120121
def urls(cls):
121-
"""Return all URLs to workflow related task and other special views.
122+
"""
123+
Return all URLs to workflow related task and other special views.
122124
123125
Example::
124126
@@ -188,7 +190,8 @@ def get_override_url(self):
188190

189191
@classmethod
190192
def get_graph(cls, color="black"):
191-
"""Return workflow graph.
193+
"""
194+
Return workflow graph.
192195
193196
Returns:
194197
(graphviz.Digraph): Directed graph of the workflow.
@@ -217,7 +220,8 @@ def get_graph(cls, color="black"):
217220

218221
@classmethod
219222
def get_graph_svg(cls):
220-
"""Return graph representation of a model workflow as SVG.
223+
"""
224+
Return graph representation of a model workflow as SVG.
221225
222226
The SVG is HTML safe and can be included in a template, e.g.:
223227
@@ -306,7 +310,8 @@ def get_instance_graph(self):
306310
return graph
307311

308312
def get_instance_graph_svg(self, output_format="svg"):
309-
"""Return graph representation of a running workflow as SVG.
313+
"""
314+
Return graph representation of a running workflow as SVG.
310315
311316
The SVG is HTML safe and can be included in a template, e.g.:
312317
@@ -331,7 +336,8 @@ def get_instance_graph_svg(self, output_format="svg"):
331336
get_instance_graph_svg.short_description = t("instance graph")
332337

333338
def get_instance_graph_mermaid(self):
334-
"""Return instance graph as Mermaid diagram syntax.
339+
"""
340+
Return instance graph as Mermaid diagram syntax.
335341
336342
This can be used with MermaidJS for client-side rendering in admin.
337343
@@ -633,12 +639,12 @@ def save(self, **kwargs):
633639

634640
def get_absolute_url(self):
635641
if self.completed:
636-
return # completed tasks have no detail view
642+
return None # completed tasks have no detail view
637643
url_name = f"{self.workflow.get_url_namespace()}:{self.name}"
638644
try:
639645
return reverse(url_name, kwargs={"pk": self.pk})
640646
except NoReverseMatch:
641-
return # no URL was defined for this task
647+
return None # no URL was defined for this task
642648

643649
@property
644650
def node(self):
@@ -672,7 +678,8 @@ def fail(self):
672678
self.save(update_fields=["status", "exception", "stacktrace"])
673679

674680
def enqueue(self, countdown=None, eta=None):
675-
"""Schedule the task for execution.
681+
"""
682+
Schedule the task for execution.
676683
677684
Args:
678685
countdown (int):
@@ -698,7 +705,8 @@ def enqueue(self, countdown=None, eta=None):
698705
)
699706

700707
def start_next_tasks(self, next_nodes: list = None):
701-
"""Start new tasks following another tasks.
708+
"""
709+
Start new tasks following another tasks.
702710
703711
Args:
704712
self (Task): The task that precedes the next tasks.

‎joeflow/runner/base.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515

1616

1717
def execute(workflow, task):
18-
"""Run the node of a machine task.
18+
"""
19+
Run the node of a machine task.
1920
2021
Returns:
2122
tuple: Whether the node executed successfully and its result.

‎joeflow/runner/django_tasks.py‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
"""Execute machine tasks with Django's task framework.
1+
"""
2+
Execute machine tasks with Django's task framework.
23
34
A task backend must be configured with the ``TASKS`` setting.
45
"""
@@ -29,7 +30,8 @@ class RetryError(Exception):
2930

3031

3132
def _get_run_after(countdown=None, eta=None):
32-
"""Return the point in time a machine task should start.
33+
"""
34+
Return the point in time a machine task should start.
3335
3436
An ``eta`` takes precedence over a ``countdown``.
3537
"""
@@ -42,7 +44,8 @@ def _get_run_after(countdown=None, eta=None):
4244

4345
@contextmanager
4446
def _retry_on_failure(task, *args, **kwargs):
45-
"""Re-enqueue a task if the wrapped code block fails.
47+
"""
48+
Re-enqueue a task if the wrapped code block fails.
4649
4750
Machine tasks are locked to prevent race conditions. Django's task
4851
framework has no retry mechanism of its own, so a task that is locked or
@@ -115,7 +118,8 @@ def _create_machine_task():
115118

116119

117120
def task_runner(*, task_pk, workflow_pk, countdown=None, eta=None):
118-
"""Schedule an asynchronous machine task.
121+
"""
122+
Schedule an asynchronous machine task.
119123
120124
Args:
121125
task_pk (int): Primary key of the task that should be executed.

‎joeflow/tasks/__init__.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
"""A task defines the behavior or a workflow.
1+
"""
2+
A task defines the behavior or a workflow.
23
34
A task can be considered as a simple transaction that changes state of a workflow.
45
There are two types of tasks, human and machine tasks.
56
"""
67

7-
from joeflow.typing import * # NoQA
8+
from joeflow.typing import *
89

9-
from .human import * # NoQA
10-
from .machine import * # NoQA
10+
from .human import *
11+
from .machine import *

‎joeflow/tasks/human.py‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,20 @@
1111

1212

1313
class StartView(StartViewMixin, generic.CreateView):
14-
"""Start a new workflow by a human with a view.
14+
"""
15+
Start a new workflow by a human with a view.
1516
1617
Starting a workflow with a view allows users to provide initial data.
1718
1819
Similar to Django's :class:`CreateView<django.views.generic.edit.CreateView>`
1920
but does not only create the workflow but also completes a tasks.
2021
"""
2122

22-
pass
23-
2423

2524
class UpdateView(TaskViewMixin, generic.UpdateView):
26-
"""Modify the workflow state and complete a human task.
25+
"""
26+
Modify the workflow state and complete a human task.
2727
2828
Similar to Django's :class:`UpdateView<django.views.generic.edit.UpdateView>`
2929
but does not only update the workflow but also completes a tasks.
3030
"""
31-
32-
pass

‎joeflow/tasks/machine.py‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
from ..typing import MACHINE
88

99
__all__ = (
10-
"Start",
1110
"Join",
11+
"Start",
1212
"Wait",
1313
)
1414

1515

1616
class Start:
17-
"""Start a new function via a callable.
17+
"""
18+
Start a new function via a callable.
1819
1920
Creates a new workflow instance and executes a start task.
2021
The start task does not do anything beyond creating the workflow.
@@ -53,7 +54,8 @@ def __call__(self, **kwargs):
5354

5455

5556
class Join:
56-
"""Wait for all parent tasks to complete before continuing the workflow.
57+
"""
58+
Wait for all parent tasks to complete before continuing the workflow.
5759
5860
Args:
5961
*parents (str): List of parent task names to wait for.
@@ -112,7 +114,8 @@ def create_task(self, workflow, prev_task):
112114

113115

114116
class Wait:
115-
"""Wait for a certain amount of time and then continue with the next tasks.
117+
"""
118+
Wait for a certain amount of time and then continue with the next tasks.
116119
117120
Args:
118121
duration (datetime.timedelta): Time to wait in time delta from creation of task.

‎joeflow/utils.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88

99
class NoDashDiGraph(gv.Digraph):
10-
"""Like `.graphviz.Digraph` but with unique nodes and edges.
10+
"""
11+
Like `.graphviz.Digraph` but with unique nodes and edges.
1112
1213
Nodes and edges are unique and their attributes will be overridden
1314
should the same node or edge be added twice. Nodes are unique by name

0 commit comments

Comments
 (0)