bpo-28556: Add a regression test to typing (GH-15396) · python/cpython@5fda09c (original) (raw)

Original file line number Diff line number Diff line change
@@ -961,6 +961,23 @@ def __init__(self, x):
961 961 self.assertIsInstance(C(1), P)
962 962 self.assertIsInstance(C(1), PG)
963 963
964 +def test_protocol_checks_after_subscript(self):
965 +class P(Protocol[T]): pass
966 +class C(P[T]): pass
967 +class Other1: pass
968 +class Other2: pass
969 +CA = C[Any]
970 +
971 +self.assertNotIsInstance(Other1(), C)
972 +self.assertNotIsSubclass(Other2, C)
973 +
974 +class D1(C[Any]): pass
975 +class D2(C[Any]): pass
976 +CI = C[int]
977 +
978 +self.assertIsInstance(D1(), C)
979 +self.assertIsSubclass(D2, C)
980 +
964 981 def test_protocols_support_register(self):
965 982 @runtime_checkable
966 983 class P(Protocol):