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

Embrace | for union of types #10725

Open
pradyunsg opened this issue Dec 12, 2021 · 2 comments
Open

Embrace | for union of types #10725

pradyunsg opened this issue Dec 12, 2021 · 2 comments
Labels
state: awaiting PR Feature discussed, PR is needed type: maintenance Related to Development and Maintenance Processes

Comments

@pradyunsg
Copy link
Member

Now Python 3.7 is the minimum, instead of:

from typing import Union
a: Union[int, str]

You can use the more concise (PEP 604):

from __future__ import annotations
a: int | str

Similarly, you can use dict and list instead of typing.Dict and typing.List etc:

https://www.python.org/dev/peps/pep-0585/#implementation

Originally posted by @hugovk in #10703 (comment)

@pradyunsg pradyunsg added type: maintenance Related to Development and Maintenance Processes state: awaiting PR Feature discussed, PR is needed labels Dec 12, 2021
@uranusjr
Copy link
Member

I’m kind of hesitant of using from __future__ import annotations. It’s probably not going to break (because too many others are already depending on it), but still...

@pfmoore
Copy link
Member

pfmoore commented Dec 14, 2021

I'd prefer to hold of on using from __future__ import annotations until the SC has made a decision on the relevant PEPs here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: awaiting PR Feature discussed, PR is needed type: maintenance Related to Development and Maintenance Processes
Projects
None yet
Development

No branches or pull requests

3 participants