Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 71af090 commit 72da4a4Copy full SHA for 72da4a4
1 file changed
Lib/test/test_typing.py
@@ -2933,6 +2933,23 @@ class E(C, BP): pass
2933
self.assertNotIsInstance(D(), E)
2934
self.assertNotIsInstance(E(), D)
2935
2936
+ def test_inheritance_from_object(self):
2937
+ # Inheritance from object is specifically allowed, unlike other nominal classes
2938
+ class P(Protocol, object):
2939
+ x: int
2940
+
2941
+ self.assertEqual(typing.get_protocol_members(P), {'x'})
2942
2943
+ class OldGeneric(Protocol, Generic[T], object):
2944
+ y: T
2945
2946
+ self.assertEqual(typing.get_protocol_members(OldGeneric), {'y'})
2947
2948
+ class NewGeneric[T](Protocol, object):
2949
+ z: T
2950
2951
+ self.assertEqual(typing.get_protocol_members(NewGeneric), {'z'})
2952
2953
def test_no_instantiation(self):
2954
class P(Protocol): pass
2955
0 commit comments