Menu

#748 Rename local changes named-parameter arguments

1.3.18
open
nobody
5
2008-07-07
2008-07-07
No

When using the Rename refactoring to rename a local variable inside a function, an occurrence of a named parameter with the same name is changed also. Example:

def t_plus_three(dt, holidays):
days = 0
while(days < 3):
dt = dt + datetime.timedelta(days = 1)
if(dt.isoweekday() < 6 and not dt in holidays):
days = days + 1
return dt

When I try to rename the local variable "days" to "biz_days", I get this:

dt = dt + datetime.timedelta(biz_days = 1)

which is of course incorrect.

That's not a big deal in this case (it produces a compile-time TypeError so you can't miss it) but could easily introduce sneaky bugs in cases where a named parameter with the new name also exists.

Discussion

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.