diff --git a/codeflash/cli_cmds/init_java.py b/codeflash/cli_cmds/init_java.py index 73822e626..a16a0a5d3 100644 --- a/codeflash/cli_cmds/init_java.py +++ b/codeflash/cli_cmds/init_java.py @@ -26,6 +26,8 @@ from codeflash.code_utils.shell_utils import get_shell_rc_path, is_powershell from codeflash.telemetry.posthog_cf import ph +_cached_theme = None + class JavaBuildTool(Enum): """Java build tools.""" @@ -57,9 +59,11 @@ class JavaSetupInfo: def _get_theme(): """Get the CodeflashTheme - imported lazily to avoid circular imports.""" - from codeflash.cli_cmds.cmd_init import CodeflashTheme - - return CodeflashTheme() + global _cached_theme + if _cached_theme is None: + from codeflash.cli_cmds.cmd_init import CodeflashTheme + _cached_theme = CodeflashTheme() + return _cached_theme def detect_java_build_tool(project_root: Path) -> JavaBuildTool: diff --git a/codeflash/code_utils/code_utils.py b/codeflash/code_utils/code_utils.py index 9244f6b11..36b9fb1f3 100644 --- a/codeflash/code_utils/code_utils.py +++ b/codeflash/code_utils/code_utils.py @@ -472,7 +472,8 @@ def validate_relative_directory_path(path: str) -> tuple[bool, str]: # Check for absolute paths, invalid characters, and validate path format error_msg = "" - if Path(path).is_absolute(): + # Use os.path.isabs() which is faster than Path().is_absolute() + if os.path.isabs(path): error_msg = "Path must be relative, not absolute" elif os.name == "nt": # Windows if any(char in _INVALID_CHARS_NT for char in path):