python-rope / rope

a python refactoring library
GNU Lesser General Public License v3.0
1.93k stars 161 forks source link

Document IntroduceParameter refactoring #122

Open Wilfred opened 9 years ago

Wilfred commented 9 years ago

I'd like to be able to do the following refactoring:

# before
def foo():
    bar(some_expr)

# after
def foo(new_param=some_expr):
    bar(new_param)

Could this be added to rope?

Additional acceptance criteria:

soupytwist commented 7 years ago

That's an interesting idea. I think there is some complexity in it, for example if the expression being moved references variables defined in the function scope.

If you would like to add this capability, we would gratefully accept a pull request.

mcepl commented 7 years ago

It seems to me a bit dangerous: mutable default arguments are evil, so the code would have to check that it doesn’t do The Bad Thing™.

lieryan commented 2 years ago

This seems to have already been supported by the IntroduceParameter refactoring.

It is currently undocumented and I don't think currently there are any editor integration currently that implements them though.