Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

a python refactoring IDE and library...

Project description

Overview

rope is a python refactoring IDE and library. The IDE uses the library to provide features like refactoring, code assist, and auto-completion. It is written in python. The IDE uses Tkinter library.

New Features

Basic Implicit Interfaces

Implicit interfaces are the interfaces that you don’t explicitly define; But you expect a group of classes to have some common attributes. These kinds of interfaces are very common in dynamic languages; Since we only have implementation inheritance and not interface inheritance. For instance:

class A(object):

    def count(self):
        pass

class B(object):

    def count(self):
        pass

def count_for(arg):
    return arg.count()

count_for(A())
count_for(B())

Here we know that there is an implicit interface defined by the function count_for that provides count(). Here when we rename A.count() we expect B.count() to be renamed, too. Currently rope supports a basic form of implicit interfaces. When you try to rename an attribute of a parameter, rope renames that attribute for all objects that have been passed to that function in different call sites. That is renaming the occurrence of count in count_for function to newcount will result in:

class A(object):

    def newcount(self):
        pass

class B(object):

    def newcount(self):
        pass

def count_for(arg):
    return arg.newcount()

count_for(A())
count_for(B())

This also works for change method signature. Note that this feature relies on rope’s object inference mechanisms to find out the parameters that are passed to a function. Also see the automatic SOI analysis that is added in this release.

Renaming Occurrences In Strings And Comments

You can tell rope to rename all occurrences of a name in comments and strings. This can be done in rename refactoring dialog by selecting its radio button or by passing docs=True to Rename.get_changes() method when using rope as a library. Rope renames names in comments and strings only when the name is visible there. For example in:

def f():
    a_var = 1
    print 'a_var = %s' % a_var

# f prints a_var

after we rename the a_var local variable in f() to new_var we would get:

def f():
    new_var = 1
    print 'new_var = %s' % new_var

# f prints a_var

This makes it safe to assume that this option does not perform wrong renames most of the time and for this reason it is by default on in the UI (though not in Rename.get_changes()).

Stoppable Refactorings

Another notable new feature is stoppable refactorings. Some refactorings might take a long time to finish (based on the size of your project). Rope now shows a dialog that has a progress bar and a stop button for these refactorings. You can also use this feature when using rope as a library. The get_changes() method of these refactorings take a new parameter called task_handle. If you want to monitor or stop these refactoring you can pass a rope.refactor. taskhandle.TaskHandle to this method. See rope.refactor.taskhandle module for more information.

Automatic SOI Analysis

Maybe the most important internal feature added in this release is automatic static object inference analysis. When turned on, it analyzes the changed scopes of a file when saving for obtaining object information; So this might make saving files a bit more time consuming. This feature is by default turned on, but you can turn it off by editing your project config.py file (available in ${your_project_root}/.ropeproject/config.py, if you’re new to rope), though that is not recommended.

Spell-Checker

The new spell-checker uses ispell/aspell if available. You can use M-$ like emacs for checking current word. You can also use C-x $ r and C-x $ b for spell-checking region and buffer.

Project details


Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page