]> 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:

Look at actual parenthesis when generating ignored leafs.
authorZsolt Dollenstein <zsol.zsol@gmail.com>
Sun, 22 Jul 2018 13:47:42 +0000 (14:47 +0100)
committerZsolt Dollenstein <zsol.zsol@gmail.com>
Sun, 22 Jul 2018 14:30:02 +0000 (15:30 +0100)
Fixes #385

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

index c34e57805f33f8cb7686670090d0f103d4bcd34b..61cb88ae6236c063ff7791c866e299900dfd8dc9 100644 (file)
--- a/README.md
+++ b/README.md
@@ -823,6 +823,7 @@ More details can be found in [CONTRIBUTING](CONTRIBUTING.md).
 ### 18.8b0
 
 * fix parsing of `__future__` imports with renames (#389)
+* fix scope of `# fmt: off` when directly preceding `yield` and other nodes (#385)
 
 ### 18.6b4
 
index 36a180da702a3a003276dc3a8e1f25b96b4abd01..c9b8be975d239b30cc2ecf4bc7723c60a34ce13e 100644 (file)
--- a/black.py
+++ b/black.py
@@ -797,18 +797,6 @@ UNPACKING_PARENTS = {
     syms.testlist_gexp,
     syms.testlist_star_expr,
 }
-SURROUNDED_BY_BRACKETS = {
-    syms.typedargslist,
-    syms.arglist,
-    syms.subscriptlist,
-    syms.vfplist,
-    syms.import_as_names,
-    syms.yield_expr,
-    syms.testlist_gexp,
-    syms.testlist_star_expr,
-    syms.listmaker,
-    syms.dictsetmaker,
-}
 TEST_DESCENDANTS = {
     syms.test,
     syms.lambdef,
@@ -1853,7 +1841,7 @@ def container_of(leaf: Leaf) -> LN:
         if parent.type == syms.file_input:
             break
 
-        if parent.type in SURROUNDED_BY_BRACKETS:
+        if parent.prev_sibling is not None and parent.prev_sibling.type in BRACKETS:
             break
 
         container = parent
index b2e9fc0ad97b755d366faad076a3e67721f02cb8..35f2889c4a2fdf3842afe1f8d57cd87ba1bae203 100644 (file)
@@ -48,6 +48,39 @@ something = {
     # fmt: off
     key: 'value',
 }
+
+def subscriptlist():
+    atom[
+        # fmt: off
+        'some big and',
+        'complex subscript',
+        # fmt: on
+        goes + here, andhere,
+       ]
+
+def import_as_names():
+    # fmt: off
+    from hello import a,        b
+    'unformatted'
+    # fmt: on
+
+def testlist_star_expr():
+    # fmt: off
+    a , b = *hello
+    'unformatted'
+    # fmt: on
+
+def yield_expr():
+    # fmt: off
+    yield hello
+    'unformatted'
+    # fmt: on
+    'formatted'
+    # fmt: off
+    ( yield hello )
+    'unformatted'
+    # fmt: on
+
 def example(session):
     # fmt: off
     result = session\
@@ -142,6 +175,7 @@ cfg.rule(
     xxxxxxxxxx_xxxxxxxxxxx_xxxxxxx_xxxxxxxxx=5
 )
 # fmt: off
+yield  'hello'
 # No formatting to the end of the file
 l=[1,2,3]
 d={'a':1,
@@ -219,6 +253,43 @@ something = {
 }
 
 
+def subscriptlist():
+    atom[
+        # fmt: off
+        'some big and',
+        'complex subscript',
+        # fmt: on
+        goes + here,
+        andhere,
+    ]
+
+
+def import_as_names():
+    # fmt: off
+    from hello import a,        b
+    'unformatted'
+    # fmt: on
+
+
+def testlist_star_expr():
+    # fmt: off
+    a , b = *hello
+    'unformatted'
+    # fmt: on
+
+
+def yield_expr():
+    # fmt: off
+    yield hello
+    'unformatted'
+    # fmt: on
+    "formatted"
+    # fmt: off
+    ( yield hello )
+    'unformatted'
+    # fmt: on
+
+
 def example(session):
     # fmt: off
     result = session\
@@ -327,6 +398,7 @@ cfg.rule(
     xxxxxxxxxx_xxxxxxxxxxx_xxxxxxx_xxxxxxxxx=5,
 )
 # fmt: off
+yield  'hello'
 # No formatting to the end of the file
 l=[1,2,3]
 d={'a':1,