Restore indent.py (#21094)

This commit is contained in:
Micha Reiser 2025-10-27 11:34:29 +01:00 committed by GitHub
parent 8a73519b25
commit 3c7f56f582
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 281 additions and 0 deletions

View file

@ -0,0 +1,55 @@
def test():
# fmt: off
a_very_small_indent
(
not_fixed
)
if True:
pass
more
# fmt: on
formatted
def test():
a_small_indent
# fmt: off
# fix under-indented comments
(or_the_inner_expression +
expressions
)
if True:
pass
# fmt: on
# fmt: off
def test():
pass
# It is necessary to indent comments because the following fmt: on comment because it otherwise becomes a trailing comment
# of the `test` function if the "proper" indentation is larger than 2 spaces.
# fmt: on
disabled + formatting;
# fmt: on
formatted;
def test():
pass
# fmt: off
"""A multiline strings
that should not get formatted"""
"A single quoted multiline \
string"
disabled + formatting;
# fmt: on
formatted;