Format function and class definitions into a single line if its body is an ellipsis (#6592)

This commit is contained in:
Tom Kuson 2023-08-21 08:02:23 +01:00 committed by GitHub
parent bb5fbb1b5c
commit 2a8d24dd4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 445 additions and 60 deletions

View file

@ -0,0 +1,102 @@
"""Compound statements with no body should be written on one line."""
if True:
...
elif True:
...
else:
...
if True:
# comment
...
elif True:
# comment
...
else:
# comment
...
if True:
... # comment
elif True:
... # comment
else:
... # comment
for i in []:
...
else:
...
for i in []:
# comment
...
else:
# comment
...
for i in []:
... # comment
else:
... # comment
while True:
...
else:
...
while True:
# comment
...
else:
# comment
...
while True:
... # comment
else:
... # comment
with True:
...
with True:
# comment
...
with True:
... # comment
match x:
case 1:
...
case 2:
# comment
...
case 3:
... # comment
try:
...
except:
...
finally:
...
try:
# comment
...
except:
# comment
...
finally:
# comment
...
try:
... # comment
except:
... # comment
finally:
... # comment

View file

@ -76,3 +76,16 @@ class Test2(A):
def b(): ...
# comment
def c(): ...
class EllipsisWithComment:
... # comment
def function_with_comment():
... # comment
class EllispsisWithMultipleTrailing: # trailing class comment
... # trailing ellipsis comment
class EllipsisWithLeadingComment:
# leading
...