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 @@ -2933,6 +2933,23 @@ class E(C, BP): pass
29332933 self .assertNotIsInstance (D (), E )
29342934 self .assertNotIsInstance (E (), D )
29352935
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+
29362953 def test_no_instantiation (self ):
29372954 class P (Protocol ): pass
29382955
You can’t perform that action at this time.
0 commit comments