#Python optional params
1 messages ยท Page 1 of 1 (latest)
Yes, optional params are supported but they're based on having a default or not, not by whether it allows None (which is what Optional[str] does).
For you to get that error it means it failed to undo the union in non_optional which is tested in https://github.com/dagger/dagger/blob/9ba00b59ddd6a15346408d98717614b93956161a/sdk/python/tests/modules/test_utils.py#L26.
Do you mind showing how you're defining that?
I've since switched Optional[str] to str | None = None which works fine
Just by that? Ok that's a bug then, it should be equivalent, thanks for letting us know ๐
No other changes to get that working
Ok, so I didn't know about this:
>>> get_origin(str | None)
<class 'types.UnionType'>
>>> get_origin(Optional[str])
typing.Union
One is a UnionType, the other is a Union ๐
I didn't know about that either