We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0a2ec48 commit 4316780Copy full SHA for 4316780
1 file changed
codeflash/code_utils/code_utils.py
@@ -427,10 +427,13 @@ def get_run_tmp_file(file_path: Path | str) -> Path:
427
return get_run_tmp_file.tmpdir_path / file_path
428
429
430
+@lru_cache(maxsize=1)
431
+def _get_site_packages_paths() -> tuple[Path, ...]:
432
+ return tuple(Path(p).resolve() for p in site.getsitepackages())
433
+
434
435
def path_belongs_to_site_packages(file_path: Path) -> bool:
- file_path_resolved = file_path.resolve()
- site_packages = [Path(p).resolve() for p in site.getsitepackages()]
- return any(file_path_resolved.is_relative_to(site_package_path) for site_package_path in site_packages)
436
+ return any(file_path.resolve().is_relative_to(sp) for sp in _get_site_packages_paths())
437
438
439
def is_class_defined_in_file(class_name: str, file_path: Path) -> bool:
0 commit comments