Skip to content

Commit

Permalink
trying to hide the __doc__ to the __call__ method as well
Browse files Browse the repository at this point in the history
this is for silebinder stuff

Signed-off-by: Nick Papior <nickpapior@gmail.com>
  • Loading branch information
zerothi committed Jul 6, 2023
1 parent 7e8006f commit 98af2b8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/sisl/io/_multiple.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,12 @@ def __init__(self,
self.slicer = slicer
self.default_slice = default_slice
self.kwargs = kwargs
update_wrapper(self, func)
self._update_doc()

def _update_doc(self):
# first update to the wrapped function
update_wrapper(self, self.__func__)

# Override name to display slice handling in help
default_slice = self.default_slice
if self.default_slice is None:
Expand Down Expand Up @@ -191,6 +193,7 @@ def _update_doc(self):
""")
try:
self.__doc__ = doc
self.__call__.__doc__ = doc
except AttributeError:
# we cannot set the __doc__ string, let it go
pass
Expand All @@ -201,6 +204,7 @@ def __call__(self, *args, **kwargs):
return self[self.default_slice](*args, **kwargs)

def __getitem__(self, key):
"""Extract sub items of multiple function calls as an indexed list """
return self.slicer(
obj=self.__self__,
func=self.__func__,
Expand All @@ -210,10 +214,12 @@ def __getitem__(self, key):

@property
def next(self):
"""Return the first element of the contained function """
return self[0]

@property
def last(self):
"""Return the last element of the contained function """
return self[-1]


Expand Down

0 comments on commit 98af2b8

Please sign in to comment.