Skip to content

Commit 88723fe

Browse files
authored
Change CLI entrypoint and allow passing task function to pytask.build. (#540)
1 parent cf599fb commit 88723fe

File tree

5 files changed

+13
-6
lines changed

5 files changed

+13
-6
lines changed

docs/source/changes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ releases are available on [PyPI](https://pypi.org/project/pytask) and
2323
- {pull}`528` improves the codecov setup and coverage.
2424
- {pull}`535` reenables and fixes tests with Jupyter.
2525
- {pull}`536` allows partialed functions to be task functions.
26+
- {pull}`540` changes the CLI entry-point and allow `pytask.build(tasks=task_func)` as
27+
the signatures suggested.
2628

2729
## 0.4.4 - 2023-12-04
2830

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Homepage = "https://pytask-dev.readthedocs.io/en/stable"
8787
Tracker = "https://github.com/pytask-dev/pytask/issues"
8888

8989
[project.scripts]
90-
pytask = "_pytask.cli:cli"
90+
pytask = "pytask:cli"
9191

9292
[tool.setuptools]
9393
include-package-data = true

src/_pytask/build.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ def build( # noqa: C901, PLR0912, PLR0913
127127
force
128128
Run tasks even though they would be skipped since nothing has changed.
129129
ignore
130-
A pattern to ignore files or directories. Refer to ``pathlib.Path.match``
131-
for more info.
130+
A pattern to ignore files or directories. Refer to ``pathlib.Path.match`` for
131+
more info.
132132
marker_expression
133133
Same as ``-m`` on the command line. Select tasks via marker expressions.
134134
max_failures
@@ -145,7 +145,7 @@ def build( # noqa: C901, PLR0912, PLR0913
145145
Start a custom debugger on errors. For example:
146146
``--pdbcls=IPython.terminal.debugger:TerminalPdb``
147147
s
148-
Shortcut for ``pytask.build(capture"no")``.
148+
Shortcut for ``capture="no"``.
149149
show_capture
150150
Choose which captured output should be shown for failed tasks.
151151
show_errors_immediately
@@ -161,7 +161,8 @@ def build( # noqa: C901, PLR0912, PLR0913
161161
strict_markers
162162
Raise errors for unknown markers.
163163
tasks
164-
A task or a collection of tasks that is passed to ``pytask.build(tasks=...)``.
164+
A task or a collection of tasks which can be callables or instances following
165+
{class}`~pytask.PTask`.
165166
task_files
166167
A pattern to describe modules that contain tasks.
167168
trace

src/_pytask/collect.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from _pytask.path import shorten_path
3939
from _pytask.reports import CollectionReport
4040
from _pytask.shared import find_duplicates
41+
from _pytask.shared import to_list
4142
from _pytask.task_utils import COLLECTED_TASKS
4243
from _pytask.task_utils import task as task_decorator
4344
from _pytask.typing import is_task_function
@@ -103,7 +104,7 @@ def _collect_from_paths(session: Session) -> None:
103104

104105
def _collect_from_tasks(session: Session) -> None:
105106
"""Collect tasks from user provided tasks via the functional interface."""
106-
for raw_task in session.config.get("tasks", ()):
107+
for raw_task in to_list(session.config.get("tasks", ())):
107108
if is_task_function(raw_task):
108109
if not hasattr(raw_task, "pytask_meta"):
109110
raw_task = task_decorator()(raw_task) # noqa: PLW2901

tests/test_execute.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,9 @@ def func(path):
988988
assert session.exit_code == ExitCode.OK
989989
assert tmp_path.joinpath("out.txt").exists()
990990

991+
session = build(tasks=task)
992+
assert session.exit_code == ExitCode.OK
993+
991994

992995
def test_collect_task(runner, tmp_path):
993996
source = """

0 commit comments

Comments
 (0)