Skip to content

Commit fadc1ed

Browse files
authored
Remove PEP-604 methods from Sentinel on Python <3.10 (#605)
We don't generally try to "backport PEP 604" on Python <3.10; this is more consistent with our features
1 parent 44de568 commit fadc1ed

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# Unreleased
2+
3+
- Remove `__or__` and `__ror__` methods from `typing_extensions.Sentinel`
4+
on Python versions <3.10. PEP 604 was introduced in Python 3.10, and
5+
`typing_extensions` does not generally attempt to backport PEP-604 methods
6+
to prior versions.
7+
18
# Release 4.14.0rc1 (May 24, 2025)
29

310
- Drop support for Python 3.8 (including PyPy-3.8). Patch by [Victorien Plot](https://github.com/Viicos).

src/typing_extensions.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4244,11 +4244,12 @@ def __repr__(self):
42444244
def __call__(self, *args, **kwargs):
42454245
raise TypeError(f"{type(self).__name__!r} object is not callable")
42464246

4247-
def __or__(self, other):
4248-
return typing.Union[self, other]
4247+
if sys.version_info >= (3, 10):
4248+
def __or__(self, other):
4249+
return typing.Union[self, other]
42494250

4250-
def __ror__(self, other):
4251-
return typing.Union[other, self]
4251+
def __ror__(self, other):
4252+
return typing.Union[other, self]
42524253

42534254
def __getstate__(self):
42544255
raise TypeError(f"Cannot pickle {type(self).__name__!r} object")

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy