Skip to content

Commit

Permalink
Fixes memoize stripping __doc__ on decorated class
Browse files Browse the repository at this point in the history
  • Loading branch information
cevans87 committed Jul 13, 2019
1 parent aa3b50f commit 6ae230f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion atools/memoize_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def __call__(cls, *args, **kwargs):
class Wrapped(decoratee, metaclass=WrappedMeta):
pass

return type(decoratee.__name__, (Wrapped,), {})
return type(decoratee.__name__, (Wrapped,), {'__doc__': decoratee.__doc__})

@staticmethod
def reset_all() -> None:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='atools',
version='0.6.1',
version='0.6.2',
packages=['', 'atools'],
python_requires='>=3.6',
url='https://github.com/cevans87/atools',
Expand Down
8 changes: 8 additions & 0 deletions test/test_memoize_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,14 @@ def foo(_: Foo) -> None:
del f
assert r() is None

def test_memoize_class_preserves_doc(self) -> None:

@memoize
class Foo:
"""Foo doc"""

assert Foo.__doc__ == "Foo doc"


if __name__ == '__main__':
unittest.main(verbosity=2)

0 comments on commit 6ae230f

Please sign in to comment.