File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -2935,6 +2935,23 @@ class E(C, BP): pass
29352935 self .assertNotIsInstance (D (), E )
29362936 self .assertNotIsInstance (E (), D )
29372937
2938+ def test_inheritance_from_object (self ):
2939+ # Inheritance from object is specifically allowed, unlike other nominal classes
2940+ class P (Protocol , object ):
2941+ x : int
2942+
2943+ self .assertEqual (typing .get_protocol_members (P ), {'x' })
2944+
2945+ class OldGeneric (Protocol , Generic [T ], object ):
2946+ y : T
2947+
2948+ self .assertEqual (typing .get_protocol_members (OldGeneric ), {'y' })
2949+
2950+ class NewGeneric [T ](Protocol , object ):
2951+ z : T
2952+
2953+ self .assertEqual (typing .get_protocol_members (NewGeneric ), {'z' })
2954+
29382955 def test_no_instantiation (self ):
29392956 class P (Protocol ): pass
29402957
You can’t perform that action at this time.
0 commit comments