pypa / pip

The Python package installer
https://pip.pypa.io/
MIT License
9.51k stars 3.02k forks source link

Embrace `|` for union of types #10725

Open pradyunsg opened 2 years ago

pradyunsg commented 2 years ago

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 https://github.com/pypa/pip/pull/10703#discussion_r767273904_

uranusjr commented 2 years ago

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 commented 2 years ago

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