X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/adce126949623da2f310e6ea3f9f83c37972582a..0cf0d68cf20bf154667042c5240f460cbf9a81b1:/black.py 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(