From: Ɓukasz Langa Date: Mon, 28 Oct 2019 16:42:46 +0000 (+0100) Subject: Explicitly close .gitignore during processing X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/0cf0d68cf20bf154667042c5240f460cbf9a81b1 Explicitly close .gitignore during processing --- diff --git a/black.py b/black.py index b3699d5..1c42f59 100644 --- a/black.py +++ b/black.py @@ -3469,10 +3469,11 @@ def get_future_imports(node: Node) -> Set[str]: 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(