Open jh0ker opened 2 years ago
I can add that it's not limited to except
clause, multiline with
statement also results in incorrect syntax:
with open(
"filepath",
) as f:
pass
becomes
def new_func():
with open(
"filepath",
)
as f:
pass
Even a multiline function call becomes weirdly indented (but still valid syntax):
print(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
)
becomes
def new_func():
print(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
)
Thank you for reporting this issue.
Environment data
Scenario
(see below for full code snippets)
Assume we have a
try/except
clause like the following somewhere in the function we want to refactor:We highlight a range of lines that contains the above lines, hit the :bulb: and select "Extract method".
Expected behaviour
Assuming the code did not have any syntax errors before, the resulting code should also be free of syntax errors.
Actual behaviour
A line break is added between
(
andas e:
in the second-to-last line of the above example, causing a syntax error.Logs
Python Language Server Log
Code Snippet / Additional information
Example Code
Result
This is a very useful project! Thanks for the great work :heart:
I noticed this bug today and although it wasn't really a big problem, i figured i'd file a report anyways since i didn't find one. Please let me know if you need any further information.