Skip to content

Commit 7bb2fdb

Browse files
Remove unnec. decorator
1 parent bfab8e1 commit 7bb2fdb

File tree

3 files changed

+2
-27
lines changed

3 files changed

+2
-27
lines changed

libsemigroups_pybind11/action.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
from .detail.cxx_wrapper import (
5555
CxxWrapper as _CxxWrapper,
5656
copy_cxx_mem_fns as _copy_cxx_mem_fns,
57-
may_return_wrapped_cxx_obj as _may_return_wrapped_cxx_obj,
5857
register_cxx_wrapped_type as _register_cxx_wrapped_type,
5958
to_cxx as _to_cxx,
6059
to_py as _to_py,
@@ -248,9 +247,8 @@ def __init__(
248247
for x in seeds:
249248
self.add_seed(x)
250249

251-
@_may_return_wrapped_cxx_obj
252250
def __getitem__(self: _Self, i: int) -> Point:
253-
return _to_cxx(self)[i]
251+
return _to_py(_to_cxx(self)[i])
254252

255253
def __len__(self: _Self) -> int:
256254
return _to_cxx(self).size()

libsemigroups_pybind11/detail/cxx_wrapper.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -233,24 +233,3 @@ def copy_cxx_mem_fns(cxx_class: pybind11_type, py_class: CxxWrapper) -> None:
233233
py_meth_name,
234234
wrap_cxx_mem_fn(getattr(cxx_class, py_meth_name)),
235235
)
236-
237-
238-
########################################################################
239-
# Decorators
240-
########################################################################
241-
242-
243-
# TODO remove usage of this just call to_py_new directly
244-
def may_return_wrapped_cxx_obj(method):
245-
"""
246-
Decorator for methods that might return a wrapped C++ object. If a wrapped
247-
C++ object is returned, then it wrapped appropriately before being
248-
returned. This is usually handled automatically above, except for
249-
special methods, which are sometimes declared explicitly.
250-
"""
251-
252-
@wraps(method)
253-
def wrapper(self, *args):
254-
return to_py(method(self, *args))
255-
256-
return wrapper

libsemigroups_pybind11/froidure_pin.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@
8282
CxxWrapper as _CxxWrapper,
8383
copy_cxx_mem_fns as _copy_cxx_mem_fns,
8484
register_cxx_wrapped_type as _register_cxx_wrapped_type,
85-
may_return_wrapped_cxx_obj as _may_return_wrapped_cxx_obj,
8685
to_cxx as _to_cxx,
8786
to_py as _to_py,
8887
wrap_cxx_free_fn as _wrap_cxx_free_fn,
@@ -174,10 +173,9 @@ def __init__(self: Self, *args) -> None:
174173
self.py_template_params = (type(gens[0]),)
175174
self.init_cxx_obj(gens)
176175

177-
@_may_return_wrapped_cxx_obj
178176
def __getitem__(self: Self, i: int) -> Element:
179177
self._raise_if_element_not_implemented()
180-
return _to_cxx(self)[i]
178+
return _to_py(_to_cxx(self)[i])
181179

182180
def __iter__(self: Self) -> Iterator:
183181
self._raise_if_element_not_implemented()

0 commit comments

Comments
 (0)