Skip to content

Commit 8a4333f

Browse files
committed
optimize check_case_conflict.parents
1 parent e71fd49 commit 8a4333f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pre_commit_hooks/check_case_conflict.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ def lower_set(iterable: Iterable[str]) -> Set[str]:
1515

1616

1717
def parents(file: str) -> Iterator[str]:
18-
file = os.path.dirname(file)
19-
while file:
20-
yield file
21-
file = os.path.dirname(file)
18+
path_parts = file.split('/')
19+
path_parts.pop()
20+
while path_parts:
21+
yield '/'.join(path_parts)
22+
path_parts.pop()
2223

2324

2425
def directories_for(files: Set[str]) -> Set[str]:

0 commit comments

Comments
 (0)