What refactoring tools do you use for Python?

What refactoring tools do you use for Python?

In the meantime, Ive tried it two tools that have some sort of integration with vim.

The first is Rope, a python refactoring library that comes with a Vim (and emacs) plug-in. I tried it for a few renames, and that definitely worked as expected. It allowed me to preview the refactoring as a diff, which is nice. It is a bit text-driven, but thats alright for me, just takes longer to learn.

The second is Bicycle Repair Man which I guess wins points on name. Also plugs into vim and emacs. Havent played much with it yet, but I remember trying it a long time ago.

Havent played with both enough yet, or tried more types of refactoring, but I will do some more hacking with them.

I would strongly recommend PyCharm – not just for refactorings. Since the first PyCharm answer was posted here a few years ago the refactoring support in PyCharm has improved significantly.

Python Refactorings available in PyCharm (last checked 2016/07/27 in PyCharm 2016.2)

  • Change Signature
  • Convert to Python Package/Module
  • Copy
  • Extract Refactorings
  • Inline
  • Invert Boolean
  • Make Top-Level Function
  • Move Refactorings
  • Push Members down
  • Pull Members up
  • Rename Refactorings
  • Safe Delete

XML refactorings (I checked in context menu in an XML file):

  • Rename
  • Move
  • Copy
  • Extract Subquery as CTE
  • Inline

Javascript refactorings:

  • Extract Parameter in JavaScript
  • Change Signature in JavaScript
  • Extract Variable in JavaScript

What refactoring tools do you use for Python?

WingIDE 4.0 (WingIDE is my python IDE of choice) will support a few refactorings, but I just tried out the latest beta, beta6, and… theres still work to be done. Retract Method works nicely, but Rename Symbol does not.

Update: The 4.0 release has fixed all of the refactoring tools. They work great now.

Leave a Reply

Your email address will not be published.