Skip to content

Commit 8e9f2bc

Browse files
committed
use is_relative_to instead of try/except
1 parent d127f58 commit 8e9f2bc

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

bough/analyzer.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,11 @@ def _find_direct_packages(
165165
directly_affected = set()
166166
strip_prefix = self.workspace_root.relative_to(self.repo_root)
167167
for file_path in changed_files:
168-
try:
168+
if Path(file_path).is_relative_to(strip_prefix):
169169
file_path_obj = Path(file_path).relative_to(strip_prefix)
170-
except ValueError as e:
171-
if "is not in the subpath" in str(e):
172-
logger.debug("Ignoring file {file_path} outside of workspace")
173-
continue
170+
else:
171+
logger.debug(f"Ignoring file {file_path} outside of workspace")
172+
continue
174173

175174
if self._matches_patterns(file_path, self.config.ignore):
176175
logger.debug(f"Ignoring file {file_path} (matches ignore patterns)")

0 commit comments

Comments
 (0)