MCPcopy
hub / github.com/reflex-dev/reflex / get_class_substate

Method get_class_substate

reflex/state.py:1090–1115  ·  view source on GitHub ↗

Get the class substate. Args: path: The path to the substate. Returns: The class substate. Raises: ValueError: If the substate is not found.

(cls, path: Sequence[str] | str)

Source from the content-addressed store, hash-verified

1088 @classmethod
1089 @functools.lru_cache
1090 def get_class_substate(cls, path: Sequence[str] | str) -> type[BaseState]:
1091 """Get the class substate.
1092
1093 Args:
1094 path: The path to the substate.
1095
1096 Returns:
1097 The class substate.
1098
1099 Raises:
1100 ValueError: If the substate is not found.
1101 """
1102 if isinstance(path, str):
1103 path = tuple(path.split("."))
1104
1105 if len(path) == 0:
1106 return cls
1107 if path[0] == cls.get_name():
1108 if len(path) == 1:
1109 return cls
1110 path = path[1:]
1111 for substate in cls.get_substates():
1112 if path[0] == substate.get_name():
1113 return substate.get_class_substate(path[1:])
1114 msg = f"Invalid path: {path}"
1115 raise ValueError(msg)
1116
1117 @classmethod
1118 def get_class_var(cls, path: Sequence[str]) -> Any:

Callers 13

add_dependencyMethod · 0.80
test_get_class_substateFunction · 0.80
get_class_varMethod · 0.80
get_var_valueMethod · 0.80
update_vars_internalMethod · 0.80
reload_state_moduleFunction · 0.80
_modify_linked_statesMethod · 0.80
__aenter__Method · 0.80
get_stateFunction · 0.80

Calls 3

splitMethod · 0.80
get_nameMethod · 0.80
get_substatesMethod · 0.45

Tested by 1

test_get_class_substateFunction · 0.64