[Misc] Add __setitem__ for LazyDict (#10469)

Signed-off-by: Yanyi Liu <wolfsonliu@163.com>
This commit is contained in:
Yanyi Liu
2024-11-20 12:44:57 +08:00
committed by GitHub
parent d200972e7f
commit 9e05252b46

View File

@ -1491,6 +1491,9 @@ class LazyDict(Mapping, Generic[T]):
self._dict[key] = self._factory[key]()
return self._dict[key]
def __setitem__(self, key: str, value: Callable[[], T]):
self._factory[key] = value
def __iter__(self):
return iter(self._factory)