Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Remove PEP-604 methods from Sentinel on Python <3.10 #605

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

Merged
merged 3 commits into from
May 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Unreleased

- Remove `__or__` and `__ror__` methods from `typing_extensions.Sentinel`
on Python versions <3.10. PEP 604 was introduced in Python 3.10, and
`typing_extensions` does not generally attempt to backport PEP-604 methods
to prior versions.

# Release 4.14.0rc1 (May 24, 2025)

- Drop support for Python 3.8 (including PyPy-3.8). Patch by [Victorien Plot](https://github.com/Viicos).
Expand Down
9 changes: 5 additions & 4 deletions src/typing_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4244,11 +4244,12 @@ def __repr__(self):
def __call__(self, *args, **kwargs):
raise TypeError(f"{type(self).__name__!r} object is not callable")

def __or__(self, other):
return typing.Union[self, other]
if sys.version_info >= (3, 10):
def __or__(self, other):
return typing.Union[self, other]

def __ror__(self, other):
return typing.Union[other, self]
def __ror__(self, other):
return typing.Union[other, self]

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