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

Support for PEP 604 (Allow writing union types as X | Y) with "<type> | None" as Optional #256

Open
xlorepdarkhelm opened this issue Feb 1, 2023 · 0 comments

Comments

@xlorepdarkhelm
Copy link

PEP 604, which was implemented in Python 3.10, allows for unions to be specified through using the pipe (union) operator. As the Optional[<type>] type already is essentially a shortcut for Union[<type>,None], the new implementation also means that Union[<type>, None] is able to be written as <type> | None. This confuses desert right now and it fails to be able to make a schema.

The current work-around is to still use the Optional[<type>] syntax, which involves importing Optional from typing. It would be nice if desert was more flexible for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant