Skip to content

Addition to #489. #491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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