Skip to content

Commit 42dae86

Browse files
committed
Addition to #489.
1 parent ca5fe23 commit 42dae86

File tree

2 files changed

+10
-23
lines changed

2 files changed

+10
-23
lines changed

docs/source/changes.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ releases are available on [PyPI](https://pypi.org/project/pytask) and
1414
caused flaky tests.
1515
- {pull}`486` adds default names to {class}`~pytask.PPathNode`.
1616
- {pull}`488` raises an error when an invalid value is used in a return annotation.
17-
- {pull}`489` simplifies parsing products and does not raise an error when a product
18-
annotation is used with the argument name `produces`. And, allow `produces` to intake
19-
any node.
17+
- {pull}`489` and {pull}`491` simplifies parsing products and does not raise an error
18+
when a product annotation is used with the argument name `produces`. And, allow
19+
`produces` to intake any node.
2020
- {pull}`490` refactors and better tests parsing of dependencies.
2121

2222
## 0.4.2 - 2023-11-8

src/_pytask/collect_utils.py

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -406,10 +406,16 @@ def parse_products_from_task_function( # noqa: C901
406406
if set(parameters_with_product_annot) - {"produces"}:
407407
has_produces_argument = True
408408

409+
if "return" in parameters_with_node_annot:
410+
parameters_with_product_annot.append("return")
411+
has_return = True
412+
409413
if parameters_with_product_annot:
410414
out = {}
411415
for parameter_name in parameters_with_product_annot:
412-
has_annotation = True
416+
if parameter_name != "return":
417+
has_annotation = True
418+
413419
if (
414420
parameter_name not in kwargs
415421
and parameter_name not in parameters_with_node_annot
@@ -448,25 +454,6 @@ def parse_products_from_task_function( # noqa: C901
448454
)
449455
out[parameter_name] = collected_products
450456

451-
if "return" in parameters_with_node_annot:
452-
has_return = True
453-
collected_products = tree_map_with_path(
454-
lambda p, x: _collect_product(
455-
session,
456-
node_path,
457-
task_name,
458-
NodeInfo(
459-
arg_name="return",
460-
path=p,
461-
value=x,
462-
task_path=task_path,
463-
task_name=task_name,
464-
),
465-
),
466-
parameters_with_node_annot["return"],
467-
)
468-
out = {"return": collected_products}
469-
470457
task_produces = obj.pytask_meta.produces if hasattr(obj, "pytask_meta") else None
471458
if task_produces:
472459
has_task_decorator = True

0 commit comments

Comments
 (0)