Skip to content

Commit 9836443

Browse files
committed
deprecation warnings for issubclass() too, why not
1 parent fc787a5 commit 9836443

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

Lib/test/test_typing.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7510,6 +7510,10 @@ def test_bytestring(self):
75107510
self.assertIsInstance(b'', ByteString)
75117511
with self.assertWarns(DeprecationWarning):
75127512
self.assertIsInstance(bytearray(b''), ByteString)
7513+
with self.assertWarns(DeprecationWarning):
7514+
self.assertIsSubclass(bytes, ByteString)
7515+
with self.assertWarns(DeprecationWarning):
7516+
self.assertIsSubclass(bytearray, ByteString)
75137517
with self.assertWarns(DeprecationWarning):
75147518
class Foo(ByteString): ...
75157519
with self.assertWarns(DeprecationWarning):

Lib/typing.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3806,6 +3806,13 @@ def __instancecheck__(self, inst):
38063806
)
38073807
return super().__instancecheck__(inst)
38083808

3809+
def __subclasscheck__(self, cls):
3810+
import warnings
3811+
warnings._deprecated(
3812+
f"{self.__module__}.{self._name}", remove=self._removal_version
3813+
)
3814+
return super().__subclasscheck__(cls)
3815+
38093816
with warnings.catch_warnings(
38103817
action="ignore", category=DeprecationWarning
38113818
):

0 commit comments

Comments
 (0)