Fix docstrings for method decorators, fixes #1621

This commit is contained in:
Dave Halter
2020-06-27 00:13:51 +02:00
parent 59ccd2da93
commit 9a54e583e7
3 changed files with 31 additions and 2 deletions

View File

@@ -422,6 +422,27 @@ def test_decorator(Script):
assert d.docstring(raw=True) == 'Nice docstring'
def test_method_decorator(Script):
code = dedent('''
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
"""wrapper docstring"""
return func(*args, **kwargs)
return wrapper
class Foo():
@decorator
def check_user(self, f):
"""Nice docstring"""
pass
Foo().check_user''')
d, = Script(code).infer()
assert d.docstring() == 'check_user(f)\n\nNice docstring'
def test_partial(Script):
code = dedent('''
def foo():