How do I change a class name throughout a project in Python? Attempting to rename a class only renames it in the current file, not in files that import it. Is that possible?
You can use the ‘Replace’ or ‘Replace in Files’ (under ‘Edit’) to change A->B in the current project or whatever.
ETA: Note that this is not, like, a magic refactor but just regular expression find and replace.
That is what I do, but I was hoping for something that is less likely to go wrong.
Refactoring should work across your project (or - across multiple files), but depending on how your project is configured you may be running into some issues.
Are you using refactoring to rename the class?
Refactoring has been a little flaky for me; it often reports finding a single instance of a var but highlights every instance. I am tending to stick with basic rename, assuming it’s just teething troubles.
Yes, I was trying to rename a class. Is there anything in particular I should look for in the project config? The project virtualenv and directory are set correctly, what else could break refactoring?
@ericp could you weigh in?