Unverified Commit 0cf0d68c authored by Łukasz Langa's avatar Łukasz Langa
Browse files

Explicitly close .gitignore during processing

parent adce1269
Loading
Loading
Loading
Loading
+5 −4
Changes for black.py: 5 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -3469,10 +3469,11 @@ def get_imports_from_children(children: List[LN]) -> Generator[str, None, None]:
def get_gitignore(root: Path) -> PathSpec:
    """ Return a PathSpec matching gitignore content if present."""
    gitignore = root / ".gitignore"
    if not gitignore.is_file():
        return PathSpec.from_lines("gitwildmatch", [])
    else:
        return PathSpec.from_lines("gitwildmatch", gitignore.open())
    lines: List[str] = []
    if gitignore.is_file():
        with gitignore.open() as gf:
            lines = gf.readlines()
    return PathSpec.from_lines("gitwildmatch", lines)


def gen_python_files_in_dir(