def test_computed_var_depends_on_parent_non_cached():
    """Child state cached var that depends on parent state un cached var is always recalculated."""
    counter = 0

    class ParentState(BaseState):
        @rx.var(cache=False)
        def no_cache_v(self) -> int:
            nonlocal counter
            counter += 1
            return counter

    class ChildState(ParentState):
        @rx.var
        def dep_v(self) -> int:
            return self.no_cache_v

    ps = ParentState()
    cs = ps.substates[ChildState.get_name()]

    assert ps.dirty_vars == set()
    assert cs.dirty_vars == set()

    dict1 = json.loads(json_dumps(ps.dict()))
    assert dict1[ps.get_full_name()] == {
        "no_cache_v": 1,
        "router": formatted_router,
    }
    assert dict1[cs.get_full_name()] == {"dep_v": 2}
    dict2 = json.loads(json_dumps(ps.dict()))
    assert dict2[ps.get_full_name()] == {
        "no_cache_v": 3,
        "router": formatted_router,
    }
    assert dict2[cs.get_full_name()] == {"dep_v": 4}
    dict3 = json.loads(json_dumps(ps.dict()))
    assert dict3[ps.get_full_name()] == {
        "no_cache_v": 5,
        "router": formatted_router,
    }
    assert dict3[cs.get_full_name()] == {"dep_v": 6}
    assert counter == 6
Child state cached var that depends on parent state un cached var is always recalculated.
tests/units/test_state.py