Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/silx/utils/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def _docstring(dest, origin):
except AttributeError:
raise ValueError("origin class has no %s method" % dest.__name__)

dest.__doc__ = origin.__doc__
functools.update_wrapper(dest, origin)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to specify the assigned and updated. According to the name of the function I would expect to have only __doc__ ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me this function is not properly named.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed I think this is related to the questions of thomas.

  • If the behavior change -> the function might be renamed
  • then if the behavior change the question is: is it safe for the existing source code ? This function is also exposed publicly so changing the behavior on other source code might be an issue.

return dest


Expand Down
13 changes: 13 additions & 0 deletions src/silx/utils/test/test_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,16 @@ def g():
pass

self.assertEqual(f.__doc__, g.__doc__)

def test_typed_function(self):
def f(a: int) -> float:
"""Docstring"""
pass

@docstring(f)
def g():
pass

self.assertEqual(f.__doc__, g.__doc__)
self.assertEqual(g.__annotations__["a"], int)
self.assertEqual(g.__annotations__["return"], float)