https://github.com/python/cpython/commit/88d95c352965d92a9916bccc3b0dac65ab83c532 commit: 88d95c352965d92a9916bccc3b0dac65ab83c532 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: AlexWaygood <[email protected]> date: 2025-04-16T15:45:29Z summary:
[3.13] typing: Add missing test case for Protocol inheritance (GH-132597) (#132603) Co-authored-by: Jelle Zijlstra <[email protected]> files: M Lib/test/test_typing.py diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 9dc719a27575a3..e1115809d4f390 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -2935,6 +2935,23 @@ class E(C, BP): pass 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 _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
