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
Describe the bug
The combo use of
@propertyand@cacheis 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