from msgspec import Struct
from functools import cached_property
class Foo(Struct):
bar: tuple[str]
@cached_property
def bar_inner(self) -> str:
return self.bar[0]
will fail because Struct does not implement __dict__. could it be possible to implement cached_property for Struct?
Traceback (most recent call last):
File "/home/scarf/repo/cata/tileset-tools/learnpillow.py", line 26, in <module>
print(meta.fallback.ascii)
^^^^^^^^^^^^^
File "/home/scarf/.asdf/installs/python/3.11.0rc2/lib/python3.11/functools.py", line 994, in __get__
raise TypeError(msg) from None
TypeError: No '__dict__' attribute on 'TileConfig' instance to cache 'fallback' property.
@property decorator does work, but would be nice to have a cached one too (if possible)
will fail because Struct does not implement
__dict__. could it be possible to implementcached_propertyfor Struct?@propertydecorator does work, but would be nice to have a cached one too (if possible)