diff --git a/reflex/components/component.py b/reflex/components/component.py index 6e4c6c37f..9466933c5 100644 --- a/reflex/components/component.py +++ b/reflex/components/component.py @@ -23,6 +23,8 @@ from typing import ( Union, ) +from typing_extensions import Self + import reflex.state from reflex.base import Base from reflex.compiler.templates import STATEFUL_COMPONENT @@ -685,7 +687,7 @@ class Component(BaseComponent, ABC): } @classmethod - def create(cls, *children, **props) -> Component: + def create(cls, *children, **props) -> Self: """Create the component. Args: diff --git a/reflex/testing.py b/reflex/testing.py index 25f9e7aac..e463ddea7 100644 --- a/reflex/testing.py +++ b/reflex/testing.py @@ -43,6 +43,7 @@ import reflex.utils.exec import reflex.utils.format import reflex.utils.prerequisites import reflex.utils.processes +from reflex.components.component import CustomComponent from reflex.config import environment from reflex.state import ( BaseState, @@ -254,6 +255,7 @@ class AppHarness: # disable telemetry reporting for tests os.environ["TELEMETRY_ENABLED"] = "false" + CustomComponent.create().get_component.cache_clear() self.app_path.mkdir(parents=True, exist_ok=True) if self.app_source is not None: app_globals = self._get_globals_from_signature(self.app_source) diff --git a/reflex/utils/exec.py b/reflex/utils/exec.py index de326dacc..b67c50036 100644 --- a/reflex/utils/exec.py +++ b/reflex/utils/exec.py @@ -253,15 +253,12 @@ def get_reload_dirs() -> list[Path]: if config.app_module is not None and config.app_module.__file__: module_path = Path(config.app_module.__file__).resolve().parent - while module_path.parent.name: - if any( - sibling_file.name == "__init__.py" - for sibling_file in module_path.parent.iterdir() - ): - # go up a level to find dir without `__init__.py` - module_path = module_path.parent - else: - break + while module_path.parent.name and any( + sibling_file.name == "__init__.py" + for sibling_file in module_path.parent.iterdir() + ): + # go up a level to find dir without `__init__.py` + module_path = module_path.parent reload_dirs = [module_path] return reload_dirs