Skip to content

Commit cfb6e20

Browse files
committed
precommit
1 parent f4ce079 commit cfb6e20

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

reflex/istate/proxy.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def __getattr__(self, name: str) -> Any:
198198
)
199199
raise ImmutableStateError(msg)
200200

201-
value = super().__getattr__(name)
201+
value = super().__getattr__(name) # pyright: ignore[reportAttributeAccessIssue]
202202
if not name.startswith("_self_") and isinstance(value, MutableProxy):
203203
# ensure mutations to these containers are blocked unless proxy is _mutable
204204
return ImmutableMutableProxy(
@@ -397,7 +397,7 @@ class MutableProxy(wrapt.ObjectProxy):
397397
}
398398

399399
# Dynamically generated classes for tracking dataclass mutations.
400-
__dataclass_proxies__: dict[type, type] = {}
400+
__dataclass_proxies__: dict[str, type] = {}
401401

402402
def __new__(cls, wrapped: Any, *args, **kwargs) -> MutableProxy:
403403
"""Create a proxy instance for a mutable object that tracks changes.
@@ -427,7 +427,7 @@ def __new__(cls, wrapped: Any, *args, **kwargs) -> MutableProxy:
427427
},
428428
)
429429
cls = cls.__dataclass_proxies__[wrapper_cls_name]
430-
return super().__new__(cls)
430+
return super().__new__(cls) # pyright: ignore[reportArgumentType]
431431

432432
def __init__(self, wrapped: Any, state: BaseState, field_name: str):
433433
"""Create a proxy for a mutable object that tracks changes.
@@ -543,7 +543,7 @@ def __getattr__(self, __name: str) -> Any:
543543
Returns:
544544
The attribute value.
545545
"""
546-
value = super().__getattr__(__name)
546+
value = super().__getattr__(__name) # pyright: ignore[reportAttributeAccessIssue]
547547

548548
if callable(value):
549549
if __name in self.__mark_dirty_attrs__:
@@ -554,7 +554,7 @@ def __getattr__(self, __name: str) -> Any:
554554
# Wrap methods that may return mutable objects tied to the state.
555555
value = wrapt.FunctionWrapper(
556556
value,
557-
self._wrap_recursive_decorator,
557+
self._wrap_recursive_decorator, # pyright: ignore[reportArgumentType]
558558
)
559559

560560
if (
@@ -564,8 +564,8 @@ def __getattr__(self, __name: str) -> Any:
564564
):
565565
# Wrap methods called on Base subclasses, which might do _anything_
566566
return wrapt.FunctionWrapper(
567-
functools.partial(value.__func__, self), # pyright: ignore [reportFunctionMemberAccess]
568-
self._wrap_recursive_decorator,
567+
functools.partial(value.__func__, self), # pyright: ignore [reportFunctionMemberAccess, reportAttributeAccessIssue]
568+
self._wrap_recursive_decorator, # pyright: ignore[reportArgumentType]
569569
)
570570

571571
if is_mutable_type(type(value)) and __name not in (
@@ -587,7 +587,7 @@ def __getitem__(self, key: Any) -> Any:
587587
Returns:
588588
The item value.
589589
"""
590-
value = super().__getitem__(key)
590+
value = super().__getitem__(key) # pyright: ignore[reportAttributeAccessIssue]
591591
if isinstance(key, slice) and isinstance(value, list):
592592
return [self._wrap_recursive(item) for item in value]
593593
# Recursively wrap mutable items retrieved through this proxy.
@@ -599,7 +599,7 @@ def __iter__(self) -> Any:
599599
Yields:
600600
Each item value (possibly wrapped in MutableProxy).
601601
"""
602-
for value in super().__iter__():
602+
for value in super().__iter__(): # pyright: ignore[reportAttributeAccessIssue]
603603
# Recursively wrap mutable items retrieved through this proxy.
604604
yield self._wrap_recursive(value)
605605

@@ -617,7 +617,7 @@ def __delitem__(self, key: str):
617617
Args:
618618
key: The key of the item.
619619
"""
620-
self._mark_dirty(super().__delitem__, args=(key,))
620+
self._mark_dirty(super().__delitem__, args=(key,)) # pyright: ignore[reportAttributeAccessIssue]
621621

622622
def __setitem__(self, key: str, value: Any):
623623
"""Set the item on the proxied object and mark state dirty.
@@ -626,7 +626,7 @@ def __setitem__(self, key: str, value: Any):
626626
key: The key of the item.
627627
value: The value of the item.
628628
"""
629-
self._mark_dirty(super().__setitem__, args=(key, value))
629+
self._mark_dirty(super().__setitem__, args=(key, value)) # pyright: ignore[reportAttributeAccessIssue]
630630

631631
def __setattr__(self, name: str, value: Any):
632632
"""Set the attribute on the proxied object and mark state dirty.

tests/units/test_state.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2432,7 +2432,7 @@ def assert_array_dirty():
24322432
assert isinstance(mutable_state.array[0], MutableProxy)
24332433
for item in mutable_state.array:
24342434
assert isinstance(item, MutableProxy)
2435-
item["foo"] = "bar"
2435+
item["foo"] = "bar" # pyright: ignore[reportArgumentType, reportCallIssue]
24362436
assert_array_dirty()
24372437

24382438

@@ -2507,7 +2507,7 @@ def assert_hashmap_dirty():
25072507
mutable_value_third_ref.append("baz") # pyright: ignore[reportAttributeAccessIssue]
25082508
assert not mutable_state.dirty_vars
25092509
# Unfortunately previous refs still will mark the state dirty... nothing doing about that
2510-
assert mutable_value.pop()
2510+
assert mutable_value.pop() # pyright: ignore[reportCallIssue]
25112511
assert_hashmap_dirty()
25122512

25132513

0 commit comments

Comments
 (0)