Skip to content
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

TypeError: TypeParser doesn't know how to handle args ((<class 'pathlib.Path'>, <class 'NoneType'>)) for <class 'types.UnionType'> #744

Closed
ghisvail opened this issue Mar 29, 2024 · 3 comments · Fixed by #742
Labels
bug Something isn't working

Comments

@ghisvail
Copy link
Collaborator

The following task definition:

@task
@annotate({"return": {"smoothed_image": Path}})
def smooth_image(input_image: Path, smoothed_image: Path | None) -> Path:
    ...

triggers an error:

TypeError: TypeParser doesn't know how to handle args ((<class 'pathlib.Path'>, <class 'NoneType'>)) for <class 'types.UnionType'> types in 'smoothed_image' field of Inputs

Notation X | None is becoming popular, and sometimes autoformatted by linters like Ruff. It would be great if Pydra's internal parsing mechanism were able to inject the necessary required / optional metadata to the fields, or at least not crash since this is a valid function definition.

@ghisvail ghisvail added the bug Something isn't working label Mar 29, 2024
@tclose
Copy link
Contributor

tclose commented Mar 30, 2024

This should be pretty straightforward

@tclose
Copy link
Contributor

tclose commented Apr 2, 2024

I have now implemented this functionality in the #742 PR

@tclose tclose closed this as completed Apr 2, 2024
@ghisvail ghisvail mentioned this issue Apr 3, 2024
2 tasks
@ghisvail
Copy link
Collaborator Author

ghisvail commented Apr 3, 2024

Reopened and added Closes attribute to the PR.

@ghisvail ghisvail reopened this Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants