Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leave alone Quarto-style comments ("#|") #3561

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

<!-- Changes that affect Black's stable style -->

- Do not reformat Quarto-style metadata comments (`#| key: value`) (#3561)

### Preview style

<!-- Changes that affect Black's preview style -->
Expand Down
9 changes: 5 additions & 4 deletions docs/the_black_code_style/current_style.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,11 @@ required due to an inner function starting immediately after.
_Black_ does not format comment contents, but it enforces two spaces between code and a
comment on the same line, and a space before the comment text begins. Some types of
comments that require specific spacing rules are respected: doc comments (`#: comment`),
section comments with long runs of hashes, and Spyder cells. Non-breaking spaces after
hashes are also preserved. Comments may sometimes be moved because of formatting
changes, which can break tools that assign special meaning to them. See
[AST before and after formatting](#ast-before-and-after-formatting) for more discussion.
section comments with long runs of hashes, Quarto-style metadata comments, and Spyder
cells. Non-breaking spaces after hashes are also preserved. Comments may sometimes be
moved because of formatting changes, which can break tools that assign special meaning
to them. See [AST before and after formatting](#ast-before-and-after-formatting) for
more discussion.

### Trailing commas

Expand Down
2 changes: 1 addition & 1 deletion src/black/comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
FMT_PASS: Final = {*FMT_OFF, *FMT_SKIP}
FMT_ON: Final = {"# fmt: on", "# fmt:on", "# yapf: enable"}

COMMENT_EXCEPTIONS = " !:#'"
COMMENT_EXCEPTIONS = " !:#'|"


@dataclass
Expand Down