mirror of
https://github.com/astral-sh/ruff
synced 2026-01-09 23:54:36 -05:00
72
crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/try.py
vendored
Normal file
72
crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/try.py
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
try:
|
||||
...
|
||||
except:
|
||||
...
|
||||
|
||||
try:
|
||||
...
|
||||
except (KeyError): # should remove brackets and be a single line
|
||||
...
|
||||
|
||||
|
||||
try: # try
|
||||
...
|
||||
# end of body
|
||||
# before except
|
||||
except (Exception, ValueError) as exc: # except line
|
||||
...
|
||||
# before except 2
|
||||
except KeyError as key: # except line 2
|
||||
...
|
||||
# in body 2
|
||||
# before else
|
||||
else:
|
||||
...
|
||||
# before finally
|
||||
finally:
|
||||
...
|
||||
|
||||
|
||||
|
||||
# with line breaks
|
||||
try: # try
|
||||
...
|
||||
# end of body
|
||||
|
||||
# before except
|
||||
except (Exception, ValueError) as exc: # except line
|
||||
...
|
||||
|
||||
# before except 2
|
||||
except KeyError as key: # except line 2
|
||||
...
|
||||
# in body 2
|
||||
|
||||
# before else
|
||||
else:
|
||||
...
|
||||
|
||||
# before finally
|
||||
finally:
|
||||
...
|
||||
|
||||
|
||||
# with line breaks
|
||||
try:
|
||||
...
|
||||
|
||||
except:
|
||||
...
|
||||
|
||||
|
||||
try:
|
||||
...
|
||||
except (Exception, Exception, Exception, Exception, Exception, Exception, Exception) as exc: # splits exception over multiple lines
|
||||
...
|
||||
|
||||
|
||||
try:
|
||||
...
|
||||
except:
|
||||
a = 10 # trailing comment1
|
||||
b = 11 # trailing comment2
|
||||
Reference in New Issue
Block a user