Unverified Commit c6c8ef76 authored by Łukasz Langa's avatar Łukasz Langa
Browse files

Fix mangling pweave and Spyder IDE special comments

Fixes #532.
parent 9372dc85
Loading
Loading
Loading
Loading
+3 −0
Changes for README.md: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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)
+3 −3
Changes for black.py: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -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

+3 −0
Changes for tests/data/comments.py: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -70,6 +70,9 @@ def __init__(self):
        """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
+6 −0
Changes for tests/data/comments3.py: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
# 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