rope
rope copied to clipboard
Extracting generator comprehension may produce invalid code
Describe the bug
Extracting generator comprehension may produce invalid code after extraction.
To Reproduce Steps to reproduce the behavior:
- Code before refactoring:
foo = sum(x for x in y)
-
Extract
x for x in y, without selecting the outer parentheses -
Expected code after extract variable refactoring:
extracted = (x for x in y)
foo = sum(extracted)
or after extract method refactoring:
foo = sum(extracted())
def extracted():
return (x for x in y)
- Instead, we currently produce invalid code when extracting local variable:
extracted = x for x in y
foo = sum(extracted)
- And "Unhandled exception in Pymode: invalid syntax (
, line 2)" when extracting method"
- [ ] fix extract variable
- [ ] fix extract method