You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because we can backport Intersection with typing_extensions making it available also to older python versions.
The & will be only available with a newer Python version and nobody wants to way 2 Years for that...
Also some people will be forced to use older version for quite some time and we need backwards compatibility for them.
Reacted by Jun Komoda, rysson, James Smith, Anabelle · エナベル and Ashrith Sagar
Because we can backport Intersection with typing_extensions making it available also to older python versions.
Right, good point. BTW, you can still use & in annotations by using from __future__ import annotations, but I could see wanting to programmatically generate types.
Late to the party here, but note that there is precedent for adding something to typing that is immediately sort-of-deprecated: PEP 646 added typing.Unpack so that we could add typing_extensions.Unpack while also adding new syntax that made it unnecessary to ever use typing.Unpack. Analogously we could add a typing.Intersection while simultaneously adding a & operator that means you (almost) never have to use typing.Intersection directly.
Reacted by Tomas R., Neil Girdhar, Kound, Jun Komoda, Miroslav Matějů, James Smith and Ashrith Sagar
Activity
NeilGirdhar commentedon Jul 28, 2023
Why create the
Intersectionname at all only to deprecate it immediately?Uniononly exists because|wasn't available.CarliJoy commentedon Jul 28, 2023
Because we can backport
Intersectionwithtyping_extensionsmaking it available also to older python versions.The
&will be only available with a newer Python version and nobody wants to way 2 Years for that...Also some people will be forced to use older version for quite some time and we need backwards compatibility for them.
NeilGirdhar commentedon Jul 28, 2023
Right, good point. BTW, you can still use
&in annotations by usingfrom __future__ import annotations, but I could see wanting to programmatically generate types.NeilGirdhar commentedon Jul 28, 2023
Also,
Intersectionshould probably not be added to Python—just to typing-extensions.Gobot1234 commentedon Jul 31, 2023
Strongly disagree with this.
typing_extensionsis meant to be for backportingtypingfeatures, not having it intypingwould create confusion.NeilGirdhar commentedon Jul 31, 2023
Good point. I guess as long as the linters push back, that's enough to discourage unnecessary use of it.
JelleZijlstra commentedon Sep 7, 2023
Late to the party here, but note that there is precedent for adding something to typing that is immediately sort-of-deprecated: PEP 646 added
typing.Unpackso that we could addtyping_extensions.Unpackwhile also adding new syntax that made it unnecessary to ever usetyping.Unpack. Analogously we could add atyping.Intersectionwhile simultaneously adding a&operator that means you (almost) never have to usetyping.Intersectiondirectly.tomasr8 commentedon Dec 14, 2023
Just an FYI, I rebased this on the latest CPython main