mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 05:25:17 +00:00
parent
9e2fd0c620
commit
1979103ec0
11 changed files with 583 additions and 123 deletions
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
|
Loading…
Add table
Add a link
Reference in a new issue