mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-09 21:04:17 +00:00
Merge pull request #626 from guykisel/case_conflict_performance
optimize check_case_conflict.parents
This commit is contained in:
commit
fe1db5fdb6
1 changed files with 5 additions and 5 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
import argparse
|
import argparse
|
||||||
import os.path
|
|
||||||
from typing import Iterable
|
from typing import Iterable
|
||||||
from typing import Iterator
|
from typing import Iterator
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
@ -15,10 +14,11 @@ def lower_set(iterable: Iterable[str]) -> Set[str]:
|
||||||
|
|
||||||
|
|
||||||
def parents(file: str) -> Iterator[str]:
|
def parents(file: str) -> Iterator[str]:
|
||||||
file = os.path.dirname(file)
|
path_parts = file.split('/')
|
||||||
while file:
|
path_parts.pop()
|
||||||
yield file
|
while path_parts:
|
||||||
file = os.path.dirname(file)
|
yield '/'.join(path_parts)
|
||||||
|
path_parts.pop()
|
||||||
|
|
||||||
|
|
||||||
def directories_for(files: Set[str]) -> Set[str]:
|
def directories_for(files: Set[str]) -> Set[str]:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue