Closed
Description
Please provide more information to help us understand the issue:
- Are you reporting a bug, or opening a feature request?
Bug.
- Please insert below the code you are checking with mypy,
or a mock-up repro if the source is private. We would appreciate
if you try to simplify your case to a minimal repro.
from typing import Any, Callable, TypeVar
_FirstDecoratee = TypeVar("_FirstDecoratee", bound=Callable[..., Any])
_SecondDecoratee = TypeVar("_SecondDecoratee", bound=Callable[..., Any])
def basic_decorator(decoratee: _FirstDecoratee) -> _FirstDecoratee:
"decorate a function"
return decoratee
def decorator_transformer(
decorator: Callable[[_SecondDecoratee], _SecondDecoratee]
) -> Callable[[_SecondDecoratee], _SecondDecoratee]:
"take a decorator and return a version of it with the same signature"
def modified_decorator(decoratee: _SecondDecoratee) -> _SecondDecoratee:
return decoratee
return modified_decorator
@basic_decorator
def unstacked() -> None:
"no decorator stack: no error"
@decorator_transformer(basic_decorator)
def stacked() -> None:
"decorator stack: this should be the same, but it's an error"
- What is the actual behavior/output?
t.py:26: error: Argument 1 has incompatible type "Callable[[], None]"; expected "_FirstDecoratee"
- What is the behavior/output you expect?
No error.
- What are the versions of mypy and Python you are using?
mypy 0.782
Python 3.8.5
- Do you see the same issue after installing mypy from Git master?
Yes (0.790+dev.ffd9d1cdff4af3b482d4dd1f871fd1dc5b39eebb)
- What are the mypy flags you are using? (For example --strict-optional)
warn_redundant_casts=True
warn_unused_ignores=True
strict_optional=True
strict_equality=True
no_implicit_optional=True
disallow_untyped_defs=True
disallow_any_generics=True