@@ -794,6 +794,81 @@ def get_attribute(self) -> None:
794
794
generate_c_property_stub ('attribute' , TestClass .attribute , output , readonly = True )
795
795
assert_equal (output , ['@property' , 'def attribute(self) -> str: ...' ])
796
796
797
+ def test_generate_c_type_with_single_arg_generic (self ) -> None :
798
+ class TestClass :
799
+ def test (self , arg0 : str ) -> None :
800
+ """
801
+ test(self: TestClass, arg0: List[int])
802
+ """
803
+ pass
804
+ output = [] # type: List[str]
805
+ imports = [] # type: List[str]
806
+ mod = ModuleType (TestClass .__module__ , '' )
807
+ generate_c_function_stub (mod , 'test' , TestClass .test , output , imports ,
808
+ self_var = 'self' , class_name = 'TestClass' )
809
+ assert_equal (output , ['def test(self, arg0: List[int]) -> Any: ...' ])
810
+ assert_equal (imports , [])
811
+
812
+ def test_generate_c_type_with_double_arg_generic (self ) -> None :
813
+ class TestClass :
814
+ def test (self , arg0 : str ) -> None :
815
+ """
816
+ test(self: TestClass, arg0: Dict[str, int])
817
+ """
818
+ pass
819
+ output = [] # type: List[str]
820
+ imports = [] # type: List[str]
821
+ mod = ModuleType (TestClass .__module__ , '' )
822
+ generate_c_function_stub (mod , 'test' , TestClass .test , output , imports ,
823
+ self_var = 'self' , class_name = 'TestClass' )
824
+ assert_equal (output , ['def test(self, arg0: Dict[str,int]) -> Any: ...' ])
825
+ assert_equal (imports , [])
826
+
827
+ def test_generate_c_type_with_nested_generic (self ) -> None :
828
+ class TestClass :
829
+ def test (self , arg0 : str ) -> None :
830
+ """
831
+ test(self: TestClass, arg0: Dict[str, List[int]])
832
+ """
833
+ pass
834
+ output = [] # type: List[str]
835
+ imports = [] # type: List[str]
836
+ mod = ModuleType (TestClass .__module__ , '' )
837
+ generate_c_function_stub (mod , 'test' , TestClass .test , output , imports ,
838
+ self_var = 'self' , class_name = 'TestClass' )
839
+ assert_equal (output , ['def test(self, arg0: Dict[str,List[int]]) -> Any: ...' ])
840
+ assert_equal (imports , [])
841
+
842
+ def test_generate_c_type_with_generic_using_other_module_first (self ) -> None :
843
+ class TestClass :
844
+ def test (self , arg0 : str ) -> None :
845
+ """
846
+ test(self: TestClass, arg0: Dict[argparse.Action, int])
847
+ """
848
+ pass
849
+ output = [] # type: List[str]
850
+ imports = [] # type: List[str]
851
+ mod = ModuleType (TestClass .__module__ , '' )
852
+ generate_c_function_stub (mod , 'test' , TestClass .test , output , imports ,
853
+ self_var = 'self' , class_name = 'TestClass' )
854
+ assert_equal (output , ['def test(self, arg0: Dict[argparse.Action,int]) -> Any: ...' ])
855
+ assert_equal (imports , ['import argparse' ])
856
+
857
+ def test_generate_c_type_with_generic_using_other_module_last (self ) -> None :
858
+ class TestClass :
859
+ def test (self , arg0 : str ) -> None :
860
+ """
861
+ test(self: TestClass, arg0: Dict[str, argparse.Action])
862
+ """
863
+ pass
864
+ output = [] # type: List[str]
865
+ imports = [] # type: List[str]
866
+ mod = ModuleType (TestClass .__module__ , '' )
867
+ generate_c_function_stub (mod , 'test' , TestClass .test , output , imports ,
868
+ self_var = 'self' , class_name = 'TestClass' )
869
+ assert_equal (output , ['def test(self, arg0: Dict[str,argparse.Action]) -> Any: ...' ])
870
+ assert_equal (imports , ['import argparse' ])
871
+
797
872
def test_generate_c_type_with_overload_pybind11 (self ) -> None :
798
873
class TestClass :
799
874
def __init__ (self , arg0 : str ) -> None :
0 commit comments