]> git.madduck.net Git - etc/vim.git/commitdiff

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:

split long del statements into multiple lines (#698)
authorJelle Zijlstra <jelle.zijlstra@gmail.com>
Sat, 23 Feb 2019 06:00:40 +0000 (22:00 -0800)
committerGitHub <noreply@github.com>
Sat, 23 Feb 2019 06:00:40 +0000 (22:00 -0800)
Fixes #693

README.md
black.py
tests/data/cantfit.py

index b25f64fb8af79682cbda9bebf8b4b4da37e990ea..57272aefc3f85078499b4eccc204a3472dac1ca6 100644 (file)
--- a/README.md
+++ b/README.md
@@ -944,10 +944,12 @@ More details can be found in [CONTRIBUTING](CONTRIBUTING.md).
 
 ### 19.2b0
 
 
 ### 19.2b0
 
-* *Black* no longer normalizes numeric literals to include `_` separators.
+* long `del` statements are now split into multiple lines (#698)
+
+* *Black* no longer normalizes numeric literals to include `_` separators (#696)
 
 * new option `--target-version` to control which Python versions
 
 * new option `--target-version` to control which Python versions
-  *Black*-formatted code should target
+  *Black*-formatted code should target (#618)
 
 ### 18.9b0
 
 
 ### 18.9b0
 
index 34bd59eacdddb8998ca7231d0c959f49f19b611e..8f50d3e217dbf1746036186691ce4cb3f7dbb1fe 100644 (file)
--- a/black.py
+++ b/black.py
@@ -1646,6 +1646,7 @@ class LineGenerator(Visitor[Line]):
         self.visit_expr_stmt = partial(v, keywords=Ø, parens=ASSIGNMENTS)
         self.visit_return_stmt = partial(v, keywords={"return"}, parens={"return"})
         self.visit_import_from = partial(v, keywords=Ø, parens={"import"})
         self.visit_expr_stmt = partial(v, keywords=Ø, parens=ASSIGNMENTS)
         self.visit_return_stmt = partial(v, keywords={"return"}, parens={"return"})
         self.visit_import_from = partial(v, keywords=Ø, parens={"import"})
+        self.visit_del_stmt = partial(v, keywords=Ø, parens={"del"})
         self.visit_async_funcdef = self.visit_async_stmt
         self.visit_decorated = self.visit_decorators
 
         self.visit_async_funcdef = self.visit_async_stmt
         self.visit_decorated = self.visit_decorators
 
@@ -3350,7 +3351,16 @@ def assert_equivalent(src: str, dst: str) -> None:
 
             if isinstance(value, list):
                 for item in value:
 
             if isinstance(value, list):
                 for item in value:
-                    if isinstance(item, ast.AST):
+                    # Ignore nested tuples within del statements, because we may insert
+                    # parentheses and they change the AST.
+                    if (
+                        field == "targets"
+                        and isinstance(node, ast.Delete)
+                        and isinstance(item, ast.Tuple)
+                    ):
+                        for item in item.elts:
+                            yield from _v(item, depth + 2)
+                    elif isinstance(item, ast.AST):
                         yield from _v(item, depth + 2)
 
             elif isinstance(value, ast.AST):
                         yield from _v(item, depth + 2)
 
             elif isinstance(value, ast.AST):
index 2a7cde348840ef7b1244b4924066b79680fdf1e2..0ab1575ffbcd0e6999e074e01b84ed6020b0efc3 100644 (file)
@@ -36,6 +36,7 @@ for key in """
     if key in self.connect_kwargs:
         raise ValueError(err.format(key))
 concatenated_strings = "some strings that are" "concatenated implicitly, so if you put them on separate" "lines it will fit"
     if key in self.connect_kwargs:
         raise ValueError(err.format(key))
 concatenated_strings = "some strings that are" "concatenated implicitly, so if you put them on separate" "lines it will fit"
+del concatenated_strings, string_variable_name, normal_function_name, normal_name, need_more_to_make_the_line_long_enough
 
 
 # output
 
 
 # output
@@ -91,3 +92,10 @@ concatenated_strings = (
     "concatenated implicitly, so if you put them on separate"
     "lines it will fit"
 )
     "concatenated implicitly, so if you put them on separate"
     "lines it will fit"
 )
+del (
+    concatenated_strings,
+    string_variable_name,
+    normal_function_name,
+    normal_name,
+    need_more_to_make_the_line_long_enough,
+)