Skip to content

Commit

Permalink
Addition to #489. (#491)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasraabe committed Nov 11, 2023
1 parent ca5fe23 commit 580f415
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 23 deletions.
6 changes: 3 additions & 3 deletions docs/source/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ releases are available on [PyPI](https://pypi.org/project/pytask) and
caused flaky tests.
- {pull}`486` adds default names to {class}`~pytask.PPathNode`.
- {pull}`488` raises an error when an invalid value is used in a return annotation.
- {pull}`489` simplifies parsing products and does not raise an error when a product
annotation is used with the argument name `produces`. And, allow `produces` to intake
any node.
- {pull}`489` and {pull}`491` simplifies parsing products and does not raise an error
when a product annotation is used with the argument name `produces`. And, allow
`produces` to intake any node.
- {pull}`490` refactors and better tests parsing of dependencies.

## 0.4.2 - 2023-11-8
Expand Down
27 changes: 7 additions & 20 deletions src/_pytask/collect_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,16 @@ def parse_products_from_task_function( # noqa: C901
if set(parameters_with_product_annot) - {"produces"}:
has_produces_argument = True

if "return" in parameters_with_node_annot:
parameters_with_product_annot.append("return")
has_return = True

if parameters_with_product_annot:
out = {}
for parameter_name in parameters_with_product_annot:
has_annotation = True
if parameter_name != "return":
has_annotation = True

if (
parameter_name not in kwargs
and parameter_name not in parameters_with_node_annot
Expand Down Expand Up @@ -448,25 +454,6 @@ def parse_products_from_task_function( # noqa: C901
)
out[parameter_name] = collected_products

if "return" in parameters_with_node_annot:
has_return = True
collected_products = tree_map_with_path(
lambda p, x: _collect_product(
session,
node_path,
task_name,
NodeInfo(
arg_name="return",
path=p,
value=x,
task_path=task_path,
task_name=task_name,
),
),
parameters_with_node_annot["return"],
)
out = {"return": collected_products}

task_produces = obj.pytask_meta.produces if hasattr(obj, "pytask_meta") else None
if task_produces:
has_task_decorator = True
Expand Down

0 comments on commit 580f415

Please sign in to comment.