2424from typing import Any , Callable
2525from typing_extensions import Self
2626from inspect import signature
27+ from functools import update_wrapper
2728
2829from _libsemigroups_pybind11 import UNDEFINED as _UNDEFINED
2930
@@ -154,21 +155,14 @@ def _cxx_obj_type_from(self: Self, samples=(), types=()) -> Any:
154155 return lookup [cxx_types ]
155156
156157
157- def _cxx_fn_signature (cxx_mem_fn : pybind11_type ) -> str :
158- return cxx_mem_fn .__doc__ .split ("\n " )[0 ]
159-
160-
161158# TODO proper annotations
162159def wrap_cxx_mem_fn (cxx_mem_fn : pybind11_type ) -> Callable :
163160 def cxx_mem_fn_wrapper (self , * args ):
164161 return getattr (self ._cxx_obj , cxx_mem_fn .__name__ )(
165162 * (to_cxx (x ) for x in args )
166163 )
167164
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 )
172166 return cxx_mem_fn_wrapper
173167
174168
@@ -177,10 +171,7 @@ def wrap_cxx_free_fn(cxx_free_fn: pybind11_type) -> Callable:
177171 def cxx_free_fn_wrapper (* args ):
178172 return cxx_free_fn (* (to_cxx (x ) for x in args ))
179173
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 )
184175 return cxx_free_fn_wrapper
185176
186177
0 commit comments