]> 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 mangling pweave and Spyder IDE special comments
authorŁukasz Langa <lukasz@langa.pl>
Wed, 26 Sep 2018 16:42:42 +0000 (09:42 -0700)
committerŁukasz Langa <lukasz@langa.pl>
Wed, 26 Sep 2018 16:42:42 +0000 (09:42 -0700)
Fixes #532.

README.md
black.py
tests/data/comments.py
tests/data/comments3.py

index 75cc1a507fef3e00f77a7be2af294ed5e3624e30..bc684ec17da4eb21752ebf855146412d5ed84aa5 100644 (file)
--- a/README.md
+++ b/README.md
@@ -953,6 +953,9 @@ More details can be found in [CONTRIBUTING](CONTRIBUTING.md).
 * cache is now populated when `--check` is successful for a file which speeds up
   consecutive checks of properly formatted unmodified files (#448)
 
+* fixed mangling [pweave](http://mpastell.com/pweave/) and
+  [Spyder IDE](https://pythonhosted.org/spyder/) special comments (#532)
+
 * fixed unstable formatting when unpacking big tuples (#267)
 
 * fixed parsing of `__future__` imports with renames (#389)
index 692f6d59b55a9044dfc6094375451c7c07a1bbba..d4b3985ebe7f1eb050c5d985ffa5ec192242aaf7 100644 (file)
--- a/black.py
+++ b/black.py
@@ -2082,8 +2082,8 @@ def list_comments(prefix: str, *, is_endmarker: bool) -> List[ProtoComment]:
 def make_comment(content: str) -> str:
     """Return a consistently formatted comment from the given `content` string.
 
-    All comments (except for "##", "#!", "#:") should have a single space between
-    the hash sign and the content.
+    All comments (except for "##", "#!", "#:", '#'", "#%%") should have a single
+    space between the hash sign and the content.
 
     If `content` didn't start with a hash sign, one is provided.
     """
@@ -2093,7 +2093,7 @@ def make_comment(content: str) -> str:
 
     if content[0] == "#":
         content = content[1:]
-    if content and content[0] not in " !:#":
+    if content and content[0] not in " !:#'%":
         content = " " + content
     return "#" + content
 
index 8ce9ffee49af68759a7605cceea6779c5b70515b..4ae3d2c2862100522b35874241c9ad97d0428826 100644 (file)
@@ -70,6 +70,9 @@ class Foo:
         """Docstring for instance attribute spam."""
 
 
+#' <h1>This is pweave!</h1>
+
+
 @fast(really=True)
 async def wat():
     async with X.open_async() as x:  # Some more comments
index e95bd21ca9edaf6af7049c06ff967b54883c92ae..fbbef6dcc6bdcf7657d59284b3b9c335116b1670 100644 (file)
@@ -1,3 +1,6 @@
+# The percent-percent comments are Spyder IDE cells.
+
+#%%
 def func():
     x = """
     a really long string
@@ -39,3 +42,6 @@ def func():
         # shared between sub-exceptions are not omitted
         _seen=set(_seen),
     )
+
+
+#%%
\ No newline at end of file