Skip to content

Commit 12cd93b

Browse files
committed
fixup! Test without warning suppression
1 parent ea4d0d3 commit 12cd93b

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

src/test_typing_extensions.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9595,9 +9595,6 @@ def test_sentinel_picklable_anonymous(self):
95959595
self.assertIs(anonymous_sentinel, pickle.loads(pickle.dumps(anonymous_sentinel, protocol=proto)))
95969596

95979597
def test_sentinel_deprecated(self):
9598-
with self.assertWarnsRegex(DeprecationWarning, r"Subclassing sentinel is forbidden by PEP 661"):
9599-
class SentinelSubclass(Sentinel):
9600-
pass
96019598

96029599
with self.assertWarnsRegex(DeprecationWarning, r"Sentinel was renamed to typing_extensions.sentinel"):
96039600
my_sentinel = Sentinel(name="my_sentinel")

src/typing_extensions.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,11 @@ def __reduce__(self) -> str:
448448
"""Reduce this sentinel to a singleton."""
449449
return self.__name__ # Module is taken from the __module__ attribute
450450

451-
@deprecated("""Sentinel was renamed to typing_extensions.sentinel""")
452-
class Sentinel(sentinel):
453-
pass
451+
with warnings.catch_warnings(): # Allow sentinel subclass for backwards compatibility
452+
warnings.simplefilter("ignore")
453+
454+
class Sentinel(sentinel):
455+
pass
454456

455457
_marker = sentinel("sentinel")
456458

0 commit comments

Comments
 (0)