Skip to content

Commit 09efb6a

Browse files
authored
Add pytask_collect_task_teardown. (#27)
1 parent f54c1a7 commit 09efb6a

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

docs/changes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ all releases are available on `Anaconda.org <https://anaconda.org/pytask/pytask>
1010
------------------
1111

1212
- :gh:`25` allows to customize the names of the task files.
13+
- :gh:`27` implements the ``pytask_collect_task_teardown`` hook specification to perform
14+
checks after a task is collected.
1315

1416

1517
0.0.6 - 2020-09-12

docs/reference_guides/hookspecs.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ Collection
7575
.. autofunction:: pytask_collect_task
7676
:noindex:
7777

78+
.. autofunction:: pytask_collect_task_teardown
79+
:noindex:
80+
7881
.. autofunction:: pytask_collect_node
7982
:noindex:
8083

@@ -96,7 +99,6 @@ duplicates are collected with :func:`pytask_collect_task`.
9699
:noindex:
97100

98101

99-
100102
Execution
101103
---------
102104

src/_pytask/collect.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ def pytask_collect_task_protocol(session, reports, path, name, obj):
128128
task = session.hook.pytask_collect_task(
129129
session=session, path=path, name=name, obj=obj
130130
)
131+
session.hook.pytask_collect_task_teardown(session=session, task=task)
131132
if task is not None:
132133
return CollectionReportTask.from_task(task)
133134

src/_pytask/hookspecs.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,15 @@ def pytask_collect_task(session, path, name, obj):
151151
"""Collect a single task."""
152152

153153

154+
@hookspec
155+
def pytask_collect_task_teardown(task):
156+
"""Perform tear-down operations when a task was collected.
157+
158+
Use this hook specification to, for example, perform checks on the collected task.
159+
160+
"""
161+
162+
154163
@hookspec(firstresult=True)
155164
def pytask_collect_node(path, node):
156165
"""Collect a node which is a dependency or a product of a task."""

0 commit comments

Comments
 (0)