showcase ObjectVar __getitem__ typing issues
This commit is contained in:
parent
5d88263cd8
commit
6f1843dbb9
@ -26,10 +26,17 @@ def serialize_bare(obj: Bare) -> dict:
|
|||||||
return {"quantity": obj.quantity}
|
return {"quantity": obj.quantity}
|
||||||
|
|
||||||
|
|
||||||
|
class Tag(rx.Base):
|
||||||
|
"""A Tag for testing."""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Base(rx.Base):
|
class Base(rx.Base):
|
||||||
"""A reflex base class with a single attribute."""
|
"""A reflex base class with a single attribute."""
|
||||||
|
|
||||||
quantity: int = 0
|
quantity: int = 0
|
||||||
|
collection: list[Tag] = []
|
||||||
|
|
||||||
|
|
||||||
class ObjectState(rx.State):
|
class ObjectState(rx.State):
|
||||||
@ -100,3 +107,6 @@ def test_typing() -> None:
|
|||||||
# Base
|
# Base
|
||||||
var = ObjectState.base
|
var = ObjectState.base
|
||||||
_ = assert_type(var, ObjectVar[Base])
|
_ = assert_type(var, ObjectVar[Base])
|
||||||
|
|
||||||
|
# Collection
|
||||||
|
ObjectState.base.collection[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user