Skip to content

Support PEP 604: Allow writing union types as X | Y #785

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

Closed
rchen152 opened this issue Jan 7, 2021 · 3 comments
Closed

Support PEP 604: Allow writing union types as X | Y #785

rchen152 opened this issue Jan 7, 2021 · 3 comments
Labels
cat: core core language and typing features enhancement

Comments

@rchen152
Copy link
Contributor

rchen152 commented Jan 7, 2021

PEP: https://www.python.org/dev/peps/pep-0604/

Introduces new syntax that we should support as soon as possible so typeshed can start using it (python/typeshed#4819).

@rchen152 rchen152 added the cat: core core language and typing features label Jan 20, 2021
rchen152 pushed a commit that referenced this issue May 17, 2021
Part of #785, though not a complete fix because this doesn't allow the `|` syntax at runtime (I think).

Resolves #924

PiperOrigin-RevId: 374269437
@commentator8
Copy link

Hi - i see the code seems to be checking if the context is 3.10 if ctx.python_version >= (3, 10) and name == "__or__": - we are using from future import __annotations__ in python 3.9. Am i correct that it still wont work for 3.9 then?

@martindemello
Copy link
Contributor

Hi @commentator8 , that's right, the feature made it into python in 3.10 so we don't support it in earlier versions, even with from future import __annotations__ or explicit string annotations.

@commentator8
Copy link

Good to know. Thanks. I've recently disabled pytype for our company's pipelines and was hoping to bring it back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat: core core language and typing features enhancement
Projects
None yet
Development

No branches or pull requests

3 participants