From 704f6472bbf5433b7e38bdfa658e705407799439 Mon Sep 17 00:00:00 2001
From: Tobias Raabe <raabe@posteo.de>
Date: Wed, 13 Mar 2024 13:07:06 +0100
Subject: [PATCH 1/7] Prevent collecting MarkGenerator.

---
 src/_pytask/collect.py | 5 +++++
 tests/test_collect.py  | 1 +
 2 files changed, 6 insertions(+)

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()

From 9b33a2f1d3679d7f63325783bc09682cd8436b1c Mon Sep 17 00:00:00 2001
From: Tobias Raabe <raabe@posteo.de>
Date: Wed, 13 Mar 2024 13:15:32 +0100
Subject: [PATCH 2/7] to changes.

---
 docs/source/changes.md | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/docs/source/changes.md b/docs/source/changes.md
index 0556fdc2..6990756d 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}`575` 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`.

From 2d1e3cbef566f90b9a8a33e4c3fc6f6114a9097e Mon Sep 17 00:00:00 2001
From: Tobias Raabe <raabe@posteo.de>
Date: Wed, 13 Mar 2024 13:16:30 +0100
Subject: [PATCH 3/7] fix.

---
 docs/source/changes.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/source/changes.md b/docs/source/changes.md
index 6990756d..3a0a8270 100644
--- a/docs/source/changes.md
+++ b/docs/source/changes.md
@@ -7,7 +7,7 @@ releases are available on [PyPI](https://pypi.org/project/pytask) and
 
 ## 0.4.6 - 2024-03-13
 
-- {pull}`575` fixes accidentally collecting `pytask.MarkGenerator` when using
+- {pull}`576` fixes accidentally collecting `pytask.MarkGenerator` when using
   `from pytask import mark`.
 
 ## 0.4.5 - 2024-01-09

From a3f8bd16fab4b811737d9bde03cecd438a23b0bb Mon Sep 17 00:00:00 2001
From: Tobias Raabe <raabe@posteo.de>
Date: Wed, 13 Mar 2024 13:18:58 +0100
Subject: [PATCH 4/7] asd


From 986e73b9ec54180e590e2622be96d3791c701991 Mon Sep 17 00:00:00 2001
From: "pre-commit-ci[bot]"
 <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date: Wed, 13 Mar 2024 12:20:20 +0000
Subject: [PATCH 5/7] [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
---
 docs/source/reference_guides/api.md                         | 6 ++----
 .../tutorials/repeating_tasks_with_different_inputs.md      | 6 ++----
 docs/source/tutorials/selecting_tasks.md                    | 3 +--
 docs/source/tutorials/skipping_tasks.md                     | 5 +++--
 docs/source/tutorials/write_a_task.md                       | 6 ++----
 5 files changed, 10 insertions(+), 16 deletions(-)

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 <pytask.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 <pytask.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}

From d3c6d920558196f86a5d34b8bef7e352dab01aa4 Mon Sep 17 00:00:00 2001
From: Tobias Raabe <raabe@posteo.de>
Date: Wed, 13 Mar 2024 13:23:10 +0100
Subject: [PATCH 6/7] Fix upath.

---
 pyproject.toml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pyproject.toml b/pyproject.toml
index 4a42ab3d..020d9599 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<2; python_version<"3.12"']
 docs = [
   "furo",
   "ipython",

From 996536aec419706a7a890e99387e5850fb1da665 Mon Sep 17 00:00:00 2001
From: Tobias Raabe <raabe@posteo.de>
Date: Wed, 13 Mar 2024 13:26:15 +0100
Subject: [PATCH 7/7] Fix upath.

---
 pyproject.toml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pyproject.toml b/pyproject.toml
index 020d9599..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<2; python_version<"3.12"']
+all = ['universal-pathlib<0.2; python_version<"3.12"']
 docs = [
   "furo",
   "ipython",