-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
addressed in next versionIssue is fixed and will appear in next published versionIssue is fixed and will appear in next published versionenhancement requestNew feature or requestNew feature or request
Description
Describe the bug
The combo use of @property and @cache is backed by the document of functools.cached_property, so it should be considered a valid use case. However, pyright seems to have some bugs in handling such case.
To Reproduce
from functools import cache
class Rectangle:
def __init__(self, length: int, width: int) -> None:
self._length = length
self._width = width
@property
@cache
def area(self) -> int:
return self._length * self._width
def is_large_rectangle(rec: Rectangle) -> bool:
return rec.area >= 100
rec = Rectangle(10, 10)
print(is_large_rectangle(rec))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
Metadata
Metadata
Assignees
Labels
addressed in next versionIssue is fixed and will appear in next published versionIssue is fixed and will appear in next published versionenhancement requestNew feature or requestNew feature or request