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

Fix unstable formatting on trailers omitted from line splitting with comments
authorŁukasz Langa <lukasz@langa.pl>
Tue, 22 May 2018 07:38:31 +0000 (00:38 -0700)
committerŁukasz Langa <lukasz@langa.pl>
Tue, 22 May 2018 07:38:31 +0000 (00:38 -0700)
Fixes #238

README.md
black.py
tests/expression.diff
tests/expression.py

index 90731d231c2171ba130134e2a52e9f59726e211a..af1f8479f358e9b55bccc917c3ef0b540a6c02a4 100644 (file)
--- a/README.md
+++ b/README.md
@@ -661,9 +661,13 @@ More details can be found in [CONTRIBUTING](CONTRIBUTING.md).
 
 * fixed optional parentheses being removed within `# fmt: off` sections (#224)
 
-* fixed invalid code produced when stars in very long imports were incorrectly 
+* fixed invalid code produced when stars in very long imports were incorrectly
   wrapped in optional parentheses (#234)
 
+* fixed unstable formatting when inline comments were moved around in
+  a trailer that was omitted from line splitting on a large expression
+  (#238) 
+
 ### 18.5b0
 
 * call chains are now formatted according to the
index afc37d99fe3ac547383c1fa3c59cfba763aefc51..e1a71e844939d9b1ad671c76440421fb439d8f90 100644 (file)
--- a/black.py
+++ b/black.py
@@ -2599,7 +2599,8 @@ def generate_trailers_to_omit(line: Line, line_length: int) -> Iterator[Set[Leaf
         if length > line_length:
             break
 
-        if leaf.type == STANDALONE_COMMENT:
+        has_inline_comment = leaf_length > len(leaf.value) + len(leaf.prefix)
+        if leaf.type == STANDALONE_COMMENT or has_inline_comment:
             break
 
         optional_brackets.discard(id(leaf))
@@ -2940,9 +2941,6 @@ def enumerate_with_length(
 
         comment: Optional[Leaf]
         for comment in line.comments_after(leaf, index):
-            if "\n" in comment.prefix:
-                return  # Oops, standalone comment!
-
             length += len(comment.value)
 
         yield index, leaf, length
index d7a03130a90a4fd87d1ba43ae1d3e00a8c179c77..4a4bb140d9e7a3dea06c961b5866c5f785132450 100644 (file)
  call(**self.screen_kwargs)
  call(b, **self.screen_kwargs)
  lukasz.langa.pl
-@@ -93,11 +114,11 @@
+@@ -93,23 +114,25 @@
  1.0 .real
  ....__class__
  list[str]
  very_long_variable_name_filters: t.List[
      t.Tuple[str, t.Union[str, t.List[t.Optional[str]]]],
  ]
+ xxxx_xxxxx_xxxx_xxx: Callable[..., List[SomeClass]] = classmethod(  # type: ignore
+     sync(async_xxxx_xxx_xxxx_xxxxx_xxxx_xxx.__func__)
+ )
+-xxxx_xxx_xxxx_xxxxx_xxxx_xxx: Callable[..., List[SomeClass]] = classmethod(  # type: ignore
+-    sync(async_xxxx_xxx_xxxx_xxxxx_xxxx_xxx.__func__)
+-)
+ xxxx_xxx_xxxx_xxxxx_xxxx_xxx: Callable[
+     ..., List[SomeClass]
+-] = classmethod(sync(async_xxxx_xxx_xxxx_xxxxx_xxxx_xxx.__func__))  # type: ignore
++] = classmethod(  # type: ignore
++    sync(async_xxxx_xxx_xxxx_xxxxx_xxxx_xxx.__func__)
++)
++xxxx_xxx_xxxx_xxxxx_xxxx_xxx: Callable[..., List[SomeClass]] = classmethod(
++    sync(async_xxxx_xxx_xxxx_xxxxx_xxxx_xxx.__func__)
++)  # type: ignore
  slice[0]
  slice[0:1]
-@@ -124,107 +145,159 @@
+ slice[0:1:2]
+ slice[:]
+ slice[:-1]
+@@ -133,107 +156,159 @@
  numpy[-(c + 1) :, d]
  numpy[:, l[-2]]
  numpy[:, ::-1]
index 9221c8eb098ffa827060776f651f41eae5377461..f35a6fd2da73155f310838b938086d832c01bdad 100644 (file)
@@ -99,6 +99,15 @@ tuple[str, int, float, dict[str, int],]
 very_long_variable_name_filters: t.List[
     t.Tuple[str, t.Union[str, t.List[t.Optional[str]]]],
 ]
+xxxx_xxxxx_xxxx_xxx: Callable[..., List[SomeClass]] = classmethod(  # type: ignore
+    sync(async_xxxx_xxx_xxxx_xxxxx_xxxx_xxx.__func__)
+)
+xxxx_xxx_xxxx_xxxxx_xxxx_xxx: Callable[..., List[SomeClass]] = classmethod(  # type: ignore
+    sync(async_xxxx_xxx_xxxx_xxxxx_xxxx_xxx.__func__)
+)
+xxxx_xxx_xxxx_xxxxx_xxxx_xxx: Callable[
+    ..., List[SomeClass]
+] = classmethod(sync(async_xxxx_xxx_xxxx_xxxxx_xxxx_xxx.__func__))  # type: ignore
 slice[0]
 slice[0:1]
 slice[0:1:2]
@@ -354,6 +363,17 @@ tuple[str, int, float, dict[str, int]]
 very_long_variable_name_filters: t.List[
     t.Tuple[str, t.Union[str, t.List[t.Optional[str]]]],
 ]
+xxxx_xxxxx_xxxx_xxx: Callable[..., List[SomeClass]] = classmethod(  # type: ignore
+    sync(async_xxxx_xxx_xxxx_xxxxx_xxxx_xxx.__func__)
+)
+xxxx_xxx_xxxx_xxxxx_xxxx_xxx: Callable[
+    ..., List[SomeClass]
+] = classmethod(  # type: ignore
+    sync(async_xxxx_xxx_xxxx_xxxxx_xxxx_xxx.__func__)
+)
+xxxx_xxx_xxxx_xxxxx_xxxx_xxx: Callable[..., List[SomeClass]] = classmethod(
+    sync(async_xxxx_xxx_xxxx_xxxxx_xxxx_xxx.__func__)
+)  # type: ignore
 slice[0]
 slice[0:1]
 slice[0:1:2]