-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pyright has problem with combo of @property
and @cache
#2133
Comments
This looks to be a limitation or a bug in the typeshed type definition for def cache(__user_function: Callable[..., _T]) -> _lru_cache_wrapper[_T]: ...
class _lru_cache_wrapper(Generic[_T]):
__wrapped__: Callable[..., _T]
def __call__(self, *args: Hashable, **kwargs: Hashable) -> _T: ...
def cache_info(self) -> _CacheInfo: ...
def cache_clear(self) -> None: ... This definition implies that the resulting cache object is callable, and calling it will return the cached value. But that's not how it works at runtime. I don't know why |
@erictraut Thank you for your patient reply. To be honest, I am not familiar with the type annotation enough to understand your introspection. If it's convenient, could you consider open an issue in the typeshed library? I really don't know how to describe this complex type annotation thing 😵 |
This will be fixed in the next release. |
This is now addressed in pyright 1.1.159, which I just published. It will also be included in the next release of pylance. |
Describe the bug
The combo use of
@property
and@cache
is backed by the document offunctools.cached_property
, so it should be considered a valid use case. However, pyright seems to have some bugs in handling such case.To Reproduce
Pyright complains that
Operator ">=" not supported for types "_lru_cache_wrapper[int]" and "Literal[100]"
.Expected behavior
There should be no error for the above code.
VS Code extension or command-line
Pyright command-line tool 1.1.158
The text was updated successfully, but these errors were encountered: