diff --git a/docs/source/changes.md b/docs/source/changes.md index 0556fdc2..3a0a8270 100644 --- a/docs/source/changes.md +++ b/docs/source/changes.md @@ -5,6 +5,11 @@ chronological order. Releases follow [semantic versioning](https://semver.org/) releases are available on [PyPI](https://pypi.org/project/pytask) and [Anaconda.org](https://anaconda.org/conda-forge/pytask). +## 0.4.6 - 2024-03-13 + +- {pull}`576` fixes accidentally collecting `pytask.MarkGenerator` when using + `from pytask import mark`. + ## 0.4.5 - 2024-01-09 - {pull}`515` enables tests with graphviz in CI. Thanks to {user}`NickCrews`. diff --git a/docs/source/reference_guides/api.md b/docs/source/reference_guides/api.md index b7efd089..284d0f79 100644 --- a/docs/source/reference_guides/api.md +++ b/docs/source/reference_guides/api.md @@ -177,8 +177,7 @@ For example: ```python @pytask.mark.timeout(10, "slow", method="thread") -def task_function(): - ... +def task_function(): ... ``` Will create and attach a {class}`Mark ` object to the collected @@ -195,8 +194,7 @@ Example for using multiple custom markers: ```python @pytask.mark.timeout(10, "slow", method="thread") @pytask.mark.slow -def task_function(): - ... +def task_function(): ... ``` ### Classes diff --git a/docs/source/tutorials/repeating_tasks_with_different_inputs.md b/docs/source/tutorials/repeating_tasks_with_different_inputs.md index 5fed02c7..aca24cb1 100644 --- a/docs/source/tutorials/repeating_tasks_with_different_inputs.md +++ b/docs/source/tutorials/repeating_tasks_with_different_inputs.md @@ -328,8 +328,7 @@ the {func}`@task ` decorator to pass keyword arguments to the task. for id_, kwargs in ID_TO_KWARGS.items(): @task(id=id_, kwargs=kwargs) - def task_create_random_data(seed, produces): - ... + def task_create_random_data(seed, produces): ... ``` Writing a function that creates `ID_TO_KWARGS` would be even more pythonic. @@ -349,8 +348,7 @@ ID_TO_KWARGS = create_parametrization() for id_, kwargs in ID_TO_KWARGS.items(): @task(id=id_, kwargs=kwargs) - def task_create_random_data(i, produces): - ... + def task_create_random_data(i, produces): ... ``` The {doc}`best-practices guide on parametrizations <../how_to_guides/bp_scaling_tasks>` diff --git a/docs/source/tutorials/selecting_tasks.md b/docs/source/tutorials/selecting_tasks.md index 266b47bf..23b06903 100644 --- a/docs/source/tutorials/selecting_tasks.md +++ b/docs/source/tutorials/selecting_tasks.md @@ -91,8 +91,7 @@ from pytask import task for i in range(2): @task - def task_parametrized(i=i): - ... + def task_parametrized(i=i): ... ``` To run the task where `i = 1`, run this command. diff --git a/docs/source/tutorials/skipping_tasks.md b/docs/source/tutorials/skipping_tasks.md index 7278ee3e..e223b1cd 100644 --- a/docs/source/tutorials/skipping_tasks.md +++ b/docs/source/tutorials/skipping_tasks.md @@ -42,8 +42,9 @@ from config import NO_LONG_RUNNING_TASKS @pytask.mark.skipif(NO_LONG_RUNNING_TASKS, reason="Skip long-running tasks.") -def task_that_takes_really_long_to_run(path: Path = Path("time_intensive_product.pkl")): - ... +def task_that_takes_really_long_to_run( + path: Path = Path("time_intensive_product.pkl"), +): ... ``` ## Further reading diff --git a/docs/source/tutorials/write_a_task.md b/docs/source/tutorials/write_a_task.md index 878f37cf..f2815449 100644 --- a/docs/source/tutorials/write_a_task.md +++ b/docs/source/tutorials/write_a_task.md @@ -136,16 +136,14 @@ from pytask import task @task -def create_random_data(): - ... +def create_random_data(): ... # The id will be ".../task_data_preparation.py::create_data". @task(name="create_data") -def create_random_data(): - ... +def create_random_data(): ... ``` ```{warning} diff --git a/pyproject.toml b/pyproject.toml index 4a42ab3d..6ca9d6a5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,7 +53,7 @@ name = "Tobias Raabe" email = "raabe@posteo.de" [project.optional-dependencies] -all = ['universal-pathlib; python_version<"3.12"'] +all = ['universal-pathlib<0.2; python_version<"3.12"'] docs = [ "furo", "ipython", diff --git a/src/_pytask/collect.py b/src/_pytask/collect.py index 3b262568..afa1c9bc 100644 --- a/src/_pytask/collect.py +++ b/src/_pytask/collect.py @@ -21,6 +21,7 @@ from _pytask.console import get_file from _pytask.exceptions import CollectionError from _pytask.exceptions import NodeNotCollectedError +from _pytask.mark import MarkGenerator from _pytask.mark_utils import get_all_marks from _pytask.mark_utils import has_mark from _pytask.node_protocols import PNode @@ -235,6 +236,10 @@ def _is_filtered_object(obj: Any) -> bool: See :issue:`507`. """ + # Filter :class:`pytask.mark.MarkGenerator` which can raise errors on some marks. + if isinstance(obj, MarkGenerator): + return True + # Filter :class:`pytask.Task` and :class:`pytask.TaskWithoutPath` objects. if isinstance(obj, PTask) and inspect.isclass(obj): return True diff --git a/tests/test_collect.py b/tests/test_collect.py index 6d01eec6..58bd99df 100644 --- a/tests/test_collect.py +++ b/tests/test_collect.py @@ -692,6 +692,7 @@ def __getattr__(self, name): result = runner.invoke(cli, [tmp_path.as_posix()]) assert result.exit_code == ExitCode.OK + assert "attr_that_definitely_does_not_exist" not in result.output @pytest.mark.end_to_end()