-
Notifications
You must be signed in to change notification settings - Fork 216
Description
Similar to #1674. We do not currently issue a complaint about this snippet, but pyre (the predecessor to pyrefly, and the reference implementation for PEP 698) does:
from typing import override
from functools import lru_cache
class Bar:
@override
@lru_cache
def method(self, x: int) -> None: ...The reason why we issue no complaint is that the lru_cache decorator transforms the function definition into an instance of _lru_cache_wrapper. We currently only recognise methods as being @override if they have Type::FunctionLiteral types in our internal model, so the transformation into an instance of _lru_cache_wrapper means that we "forget" that the method was decorated with @override. To fix this issue, we may need to treat the @override decorator more like a type qualifier that "survives" the transformations from a function-literal type to a callable type and then to an _lru_cache_wrapper type.
Mypy also issues a diagnostic on this snippet. At time of writing, neither pyright nor pyrefly do, however. Note that pyright has an open issue from a user that requests this feature.