summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_typing.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_typing.py')
-rw-r--r--Lib/test/test_typing.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py
index 16c5a52..5b05ebe 100644
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -4554,6 +4554,33 @@ class ProtocolTests(BaseTestCase):
)
self.assertIs(type(exc.__cause__), CustomError)
+ def test_isinstance_with_deferred_evaluation_of_annotations(self):
+ @runtime_checkable
+ class P(Protocol):
+ def meth(self):
+ ...
+
+ class DeferredClass:
+ x: undefined
+
+ class DeferredClassImplementingP:
+ x: undefined | int
+
+ def __init__(self):
+ self.x = 0
+
+ def meth(self):
+ ...
+
+ # override meth with a non-method attribute to make it part of __annotations__ instead of __dict__
+ class SubProtocol(P, Protocol):
+ meth: undefined
+
+
+ self.assertIsSubclass(SubProtocol, P)
+ self.assertNotIsInstance(DeferredClass(), P)
+ self.assertIsInstance(DeferredClassImplementingP(), P)
+
def test_deferred_evaluation_of_annotations(self):
class DeferredProto(Protocol):
x: DoesNotExist