File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
test-data/stubgen/pybind11_mypy_demo Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -129,6 +129,11 @@ def is_c_type(obj: object) -> bool:
129129 return inspect .isclass (obj ) or type (obj ) is type (int )
130130
131131
132+ def is_pybind11_overloaded_function_docstring (docstr : str , name : str ) -> bool :
133+ return docstr .startswith ("{}(*args, **kwargs)\n " .format (name ) +
134+ "Overloaded function.\n \n " )
135+
136+
132137def generate_c_function_stub (module : ModuleType ,
133138 name : str ,
134139 obj : object ,
@@ -160,6 +165,9 @@ def generate_c_function_stub(module: ModuleType,
160165 else :
161166 docstr = getattr (obj , '__doc__' , None )
162167 inferred = infer_sig_from_docstring (docstr , name )
168+ if inferred and is_pybind11_overloaded_function_docstring (docstr , name ):
169+ # Remove pybind11 umbrella (*args, **kwargs) for overloaded functions
170+ del inferred [- 1 ]
163171 if not inferred :
164172 if class_name and name not in sigs :
165173 inferred = [FunctionSig (name , args = infer_method_sig (name ), ret_type = ret_type )]
Original file line number Diff line number Diff line change @@ -48,13 +48,9 @@ class Point:
4848 @overload
4949 def __init__ (self , x : float , y : float ) -> None : ...
5050 @overload
51- def __init__ (* args , ** kwargs ) -> Any : ...
52- @overload
5351 def distance_to (self , x : float , y : float ) -> float : ...
5452 @overload
5553 def distance_to (self , other : Point ) -> float : ...
56- @overload
57- def distance_to (* args , ** kwargs ) -> Any : ...
5854 @property
5955 def angle_unit (self ) -> Point .AngleUnit : ...
6056 @angle_unit .setter
You can’t perform that action at this time.
0 commit comments