From d4ec8de056b4585c03e0fbaaf35934a333a6f4be Mon Sep 17 00:00:00 2001 From: SdgJlbl Date: Mon, 9 Sep 2024 16:28:47 +0200 Subject: [PATCH] chore: refactor _ignore_files in dependency management to leverage is_relative_to Signed-off-by: SdgJlbl --- substrafl/dependency/path_management.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/substrafl/dependency/path_management.py b/substrafl/dependency/path_management.py index adecf80e..8fbcc212 100644 --- a/substrafl/dependency/path_management.py +++ b/substrafl/dependency/path_management.py @@ -152,13 +152,9 @@ def copy_paths( def _ignore_files(expanded_excluded, dest_dir): def _ignore_files(path: str, names: List[str]) -> Set[str]: p = Path(path).resolve() - - # Replicate is_relative_to, added in Python 3.9 - try: - p.relative_to(dest_dir.resolve()) - except ValueError: - return set(name for name in names if p / name in expanded_excluded) - else: + if p.is_relative_to(dest_dir.resolve()): return set(names) + else: + return set(name for name in names if p / name in expanded_excluded) return _ignore_files