diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 9dc719a2757..e1115809d4f 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -2935,6 +2935,23 @@ class ProtocolTests(BaseTestCase): self.assertNotIsInstance(D(), E) self.assertNotIsInstance(E(), D) + def test_inheritance_from_object(self): + # Inheritance from object is specifically allowed, unlike other nominal classes + class P(Protocol, object): + x: int + + self.assertEqual(typing.get_protocol_members(P), {'x'}) + + class OldGeneric(Protocol, Generic[T], object): + y: T + + self.assertEqual(typing.get_protocol_members(OldGeneric), {'y'}) + + class NewGeneric[T](Protocol, object): + z: T + + self.assertEqual(typing.get_protocol_members(NewGeneric), {'z'}) + def test_no_instantiation(self): class P(Protocol): pass