@@ -187,6 +187,8 @@ def test_find_unique_signatures(self) -> None:
187
187
def test_infer_sig_from_docstring (self ) -> None :
188
188
assert_equal (infer_sig_from_docstring ('\n func(x) - y' , 'func' ),
189
189
[FunctionSig (name = 'func' , args = [ArgSig (name = 'x' )], ret_type = 'Any' )])
190
+ assert_equal (infer_sig_from_docstring ('\n func(x)' , 'func' ),
191
+ [FunctionSig (name = 'func' , args = [ArgSig (name = 'x' )], ret_type = 'Any' )])
190
192
191
193
assert_equal (infer_sig_from_docstring ('\n func(x, Y_a=None)' , 'func' ),
192
194
[FunctionSig (name = 'func' ,
@@ -218,6 +220,13 @@ def test_infer_sig_from_docstring(self) -> None:
218
220
[FunctionSig (name = 'func' , args = [ArgSig (name = 'x' , type = 'int' , default = True )],
219
221
ret_type = 'Any' )])
220
222
223
+ assert_equal (infer_sig_from_docstring ('\n func(x=3)' , 'func' ),
224
+ [FunctionSig (name = 'func' , args = [ArgSig (name = 'x' , type = None , default = True )],
225
+ ret_type = 'Any' )])
226
+
227
+ assert_equal (infer_sig_from_docstring ('\n func() -> int' , 'func' ),
228
+ [FunctionSig (name = 'func' , args = [], ret_type = 'int' )])
229
+
221
230
assert_equal (infer_sig_from_docstring ('\n func(x: int=3) -> int' , 'func' ),
222
231
[FunctionSig (name = 'func' , args = [ArgSig (name = 'x' , type = 'int' , default = True )],
223
232
ret_type = 'int' )])
@@ -737,6 +746,34 @@ def test(self, arg0: str) -> None:
737
746
assert_equal (output , ['def test(self, arg0: int) -> Any: ...' ])
738
747
assert_equal (imports , [])
739
748
749
+ def test_generate_c_type_with_docstring_no_self_arg (self ) -> None :
750
+ class TestClass :
751
+ def test (self , arg0 : str ) -> None :
752
+ """
753
+ test(arg0: int)
754
+ """
755
+ pass
756
+ output = [] # type: List[str]
757
+ imports = [] # type: List[str]
758
+ mod = ModuleType (TestClass .__module__ , '' )
759
+ generate_c_function_stub (mod , 'test' , TestClass .test , output , imports ,
760
+ self_var = 'self' , class_name = 'TestClass' )
761
+ assert_equal (output , ['def test(self, arg0: int) -> Any: ...' ])
762
+ assert_equal (imports , [])
763
+
764
+ def test_generate_c_type_classmethod (self ) -> None :
765
+ class TestClass :
766
+ @classmethod
767
+ def test (cls , arg0 : str ) -> None :
768
+ pass
769
+ output = [] # type: List[str]
770
+ imports = [] # type: List[str]
771
+ mod = ModuleType (TestClass .__module__ , '' )
772
+ generate_c_function_stub (mod , 'test' , TestClass .test , output , imports ,
773
+ self_var = 'cls' , class_name = 'TestClass' )
774
+ assert_equal (output , ['def test(cls, *args, **kwargs) -> Any: ...' ])
775
+ assert_equal (imports , [])
776
+
740
777
def test_generate_c_type_with_docstring_empty_default (self ) -> None :
741
778
class TestClass :
742
779
def test (self , arg0 : str = "" ) -> None :
0 commit comments