Open
Description
openedon Nov 1, 2018
When a decorator changes the return type of a function, that change is not detected.
Steps to reproduce
from typing import Callable
from functools import wraps
def cast_to_str(func) -> Callable[..., str]:
@wraps(func)
def wrapper(*args, **kwargs):
return str(func(*args, **kwargs))
return wrapper
@cast_to_str
def get_num() -> int:
return 5
get_num().strip()
# [no-member] Instance of 'int' has no 'strip' member
Current behavior
Return type of decorated function is set by the function declaration
Expected behavior
Return type of the function set by decorator
pylint --version output
pylint 2.1.1
astroid 2.0.4
Python 3.6.5 (default, May 14 2018, 11:01:09)
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment