24
24
from typing import Any , Callable
25
25
from typing_extensions import Self
26
26
from inspect import signature
27
+ from functools import update_wrapper
27
28
28
29
from _libsemigroups_pybind11 import UNDEFINED as _UNDEFINED
29
30
@@ -154,21 +155,14 @@ def _cxx_obj_type_from(self: Self, samples=(), types=()) -> Any:
154
155
return lookup [cxx_types ]
155
156
156
157
157
- def _cxx_fn_signature (cxx_mem_fn : pybind11_type ) -> str :
158
- return cxx_mem_fn .__doc__ .split ("\n " )[0 ]
159
-
160
-
161
158
# TODO proper annotations
162
159
def wrap_cxx_mem_fn (cxx_mem_fn : pybind11_type ) -> Callable :
163
160
def cxx_mem_fn_wrapper (self , * args ):
164
161
return getattr (self ._cxx_obj , cxx_mem_fn .__name__ )(
165
162
* (to_cxx (x ) for x in args )
166
163
)
167
164
168
- cxx_mem_fn_wrapper .__name__ = cxx_mem_fn .__name__
169
- cxx_mem_fn_wrapper .__doc__ = cxx_mem_fn .__doc__
170
- cxx_mem_fn_wrapper .__signature__ = _cxx_fn_signature (cxx_mem_fn )
171
-
165
+ update_wrapper (cxx_mem_fn_wrapper , cxx_mem_fn )
172
166
return cxx_mem_fn_wrapper
173
167
174
168
@@ -177,10 +171,7 @@ def wrap_cxx_free_fn(cxx_free_fn: pybind11_type) -> Callable:
177
171
def cxx_free_fn_wrapper (* args ):
178
172
return cxx_free_fn (* (to_cxx (x ) for x in args ))
179
173
180
- cxx_free_fn_wrapper .__name__ = cxx_free_fn .__name__
181
- cxx_free_fn_wrapper .__doc__ = cxx_free_fn .__doc__
182
- cxx_free_fn_wrapper .__signature__ = _cxx_fn_signature (cxx_free_fn )
183
-
174
+ update_wrapper (cxx_free_fn_wrapper , cxx_free_fn )
184
175
return cxx_free_fn_wrapper
185
176
186
177
0 commit comments