Skip to content

Commit

Permalink
REFACTOR: clean up wrapper code (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
j-ittner authored Jan 26, 2021
1 parent 7e22210 commit 31c06dd
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions src/sklearndf/wrapper/_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ def _mirror_attributes(
delegate=member,
)

if alias:
if alias is not None:
setattr(wrapper, name, alias)


Expand All @@ -1161,21 +1161,16 @@ def _forwarder(self, *args, **kwargs) -> Any:
_update_wrapper(wrapper=function, wrapped=delegate, wrapper_module=module)
function.__doc__ = f"See :meth:`{full_name}`"
return function
elif inspect.isdatadescriptor(delegate):
# noinspection PyShadowingNames
return property(
fget=lambda self: delegate.__get__(self._native_estimator),
fset=lambda self, value: delegate.__set__(self._native_estimator, value),
fdel=lambda self: delegate.__delete__(self._native_estimator),
doc=f"See documentation of :class:`{class_name}`.",
)
else:
docstring = f"See documentation of :class:`{class_name}`."
if inspect.isdatadescriptor(delegate):
# noinspection PyShadowingNames
return property(
fget=lambda self: delegate.__get__(self._native_estimator),
fset=lambda self, value: delegate.__set__(
self._native_estimator, value
),
fdel=lambda self: delegate.__delete__(self._native_estimator),
doc=docstring,
)
else:
# noinspection PyShadowingNames
return None
return None


def _update_wrapper(wrapper: Any, wrapped: Any, wrapper_module: str) -> None:
Expand Down

0 comments on commit 31c06dd

Please # to comment.