Validate the dependencies of the vars in the app. Args: state: The state to validate the dependencies for. Raises: VarDependencyError: When a computed var has an invalid dependency.
(self, state: type[BaseState] | None = None)
| 1260 | self.add_page(render, **kwargs) |
| 1261 | |
| 1262 | def _validate_var_dependencies(self, state: type[BaseState] | None = None) -> None: |
| 1263 | """Validate the dependencies of the vars in the app. |
| 1264 | |
| 1265 | Args: |
| 1266 | state: The state to validate the dependencies for. |
| 1267 | |
| 1268 | Raises: |
| 1269 | VarDependencyError: When a computed var has an invalid dependency. |
| 1270 | """ |
| 1271 | if not self._state: |
| 1272 | return |
| 1273 | |
| 1274 | if not state: |
| 1275 | state = self._state |
| 1276 | |
| 1277 | for var in state.computed_vars.values(): |
| 1278 | if not var._cache: |
| 1279 | continue |
| 1280 | deps = var._deps(objclass=state) |
| 1281 | for state_name, dep_set in deps.items(): |
| 1282 | state_cls = ( |
| 1283 | state.get_root_state().get_class_substate(state_name) |
| 1284 | if state_name != state.get_full_name() |
| 1285 | else state |
| 1286 | ) |
| 1287 | for dep in dep_set: |
| 1288 | if dep not in state_cls.vars and dep not in state_cls.backend_vars: |
| 1289 | msg = f"ComputedVar {var._name} on state {state.__name__} has an invalid dependency {state_name}.{dep}" |
| 1290 | raise exceptions.VarDependencyError(msg) |
| 1291 | |
| 1292 | for substate in state.get_substates(): |
| 1293 | self._validate_var_dependencies(substate) |
| 1294 | |
| 1295 | def _compile( |
| 1296 | self, |
no test coverage detected