]> git.madduck.net Git - etc/vim.git/blobdiff - black.py

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Explicitly close .gitignore during processing
[etc/vim.git] / black.py
index b3699d595f602e3bcd377fefa111d872a62b8f64..1c42f59054d0e0d228888e219a59db78e58d7c54 100644 (file)
--- 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(