From 6f1843dbb9095c7a46233a6b64a1315dbac37a13 Mon Sep 17 00:00:00 2001 From: Benedikt Bartscher Date: Thu, 14 Nov 2024 00:01:02 +0100 Subject: [PATCH] showcase ObjectVar __getitem__ typing issues --- tests/units/vars/test_object.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/units/vars/test_object.py b/tests/units/vars/test_object.py index efcb21166..b2025cd49 100644 --- a/tests/units/vars/test_object.py +++ b/tests/units/vars/test_object.py @@ -26,10 +26,17 @@ def serialize_bare(obj: Bare) -> dict: return {"quantity": obj.quantity} +class Tag(rx.Base): + """A Tag for testing.""" + + pass + + class Base(rx.Base): """A reflex base class with a single attribute.""" quantity: int = 0 + collection: list[Tag] = [] class ObjectState(rx.State): @@ -100,3 +107,6 @@ def test_typing() -> None: # Base var = ObjectState.base _ = assert_type(var, ObjectVar[Base]) + + # Collection + ObjectState.base.collection[0]