Indent statements in suppressed ranges (#6507)

This commit is contained in:
Micha Reiser 2023-08-15 08:00:35 +02:00 committed by GitHub
parent e1e213decf
commit 232b44a8ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 852 additions and 59 deletions

View file

@ -0,0 +1,3 @@
[mixed_space_and_tab.py]
generated_code = true
ij_formatter_enabled = false

View file

@ -10,8 +10,13 @@ a + b # a trailing comment
def test():
pass
# trailing comment that falls into the verbatim range
# under indent
def nested():
...
# trailing comment that falls into the verbatim range
# trailing outer comment
# fmt: on
a + b

View file

@ -0,0 +1,8 @@
[
{
"indent_style": { "Space": 4 }
},
{
"indent_style": { "Space": 2 }
}
]

View file

@ -0,0 +1,11 @@
[
{
"indent_style": { "Space": 4 }
},
{
"indent_style": { "Space": 1 }
},
{
"indent_style": "Tab"
}
]

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;

View file

@ -0,0 +1,11 @@
[
{
"indent_style": { "Space": 4 }
},
{
"indent_style": { "Space": 2 }
},
{
"indent_style": "Tab"
}
]

View file

@ -0,0 +1,15 @@
def test():
# fmt: off
a_very_small_indent
(
not_fixed
)
if True:
# Fun tab, space, tab, space. Followed by space, tab, tab, space
pass
more
else:
other
# fmt: on