File tree 2 files changed +8
-4
lines changed
test-data/stubgen/pybind11_mypy_demo
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:
129
129
return inspect .isclass (obj ) or type (obj ) is type (int )
130
130
131
131
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
+
132
137
def generate_c_function_stub (module : ModuleType ,
133
138
name : str ,
134
139
obj : object ,
@@ -160,6 +165,9 @@ def generate_c_function_stub(module: ModuleType,
160
165
else :
161
166
docstr = getattr (obj , '__doc__' , None )
162
167
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 ]
163
171
if not inferred :
164
172
if class_name and name not in sigs :
165
173
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:
48
48
@overload
49
49
def __init__ (self , x : float , y : float ) -> None : ...
50
50
@overload
51
- def __init__ (* args , ** kwargs ) -> Any : ...
52
- @overload
53
51
def distance_to (self , x : float , y : float ) -> float : ...
54
52
@overload
55
53
def distance_to (self , other : Point ) -> float : ...
56
- @overload
57
- def distance_to (* args , ** kwargs ) -> Any : ...
58
54
@property
59
55
def angle_unit (self ) -> Point .AngleUnit : ...
60
56
@angle_unit .setter
You can’t perform that action at this time.
0 commit comments