@@ -717,6 +717,32 @@ def test_generic_is_subclass3():
717
717
assert not TypeParser .is_subclass (ty .List [float ], ty .List [int ])
718
718
719
719
720
+ def test_generic_is_subclass4 ():
721
+ class MyTuple (tuple ):
722
+ pass
723
+
724
+ class A :
725
+ pass
726
+
727
+ class B (A ):
728
+ pass
729
+
730
+ assert TypeParser .is_subclass (MyTuple [A ], ty .Tuple [A ])
731
+ assert TypeParser .is_subclass (ty .Tuple [B ], ty .Tuple [A ])
732
+ assert TypeParser .is_subclass (MyTuple [B ], ty .Tuple [A ])
733
+ assert not TypeParser .is_subclass (ty .Tuple [A ], ty .Tuple [B ])
734
+ assert not TypeParser .is_subclass (ty .Tuple [A ], MyTuple [A ])
735
+ assert not TypeParser .is_subclass (MyTuple [A ], ty .Tuple [B ])
736
+ assert TypeParser .is_subclass (MyTuple [A , int ], ty .Tuple [A , int ])
737
+ assert TypeParser .is_subclass (ty .Tuple [B , int ], ty .Tuple [A , int ])
738
+ assert TypeParser .is_subclass (MyTuple [B , int ], ty .Tuple [A , int ])
739
+ assert TypeParser .is_subclass (MyTuple [int , B ], ty .Tuple [int , A ])
740
+ assert not TypeParser .is_subclass (MyTuple [B , int ], ty .Tuple [int , A ])
741
+ assert not TypeParser .is_subclass (MyTuple [int , B ], ty .Tuple [A , int ])
742
+ assert not TypeParser .is_subclass (MyTuple [B , int ], ty .Tuple [A ])
743
+ assert not TypeParser .is_subclass (MyTuple [B ], ty .Tuple [A , int ])
744
+
745
+
720
746
def test_type_is_instance1 ():
721
747
assert TypeParser .is_instance (File , ty .Type [File ])
722
748
0 commit comments