Rope is a Python refactoring library.


Rope can be easily installed with

$pipenv install rope


Now we first import the Project type and instantiate it with the path to the project:

from rope.base.project import Project

proj = Project("requests")

This creates a project folder named .ropeproject in our project.

[ for f in proj.get_files()]

The proj variable can execute a number of commands such as get_files and get_file. In the following example we use this to assign the variable api to the file

!cp requests/ requests/
api = proj.get_file("")
from rope.refactor.rename import Rename

change = Rename(proj, api).get_changes("")
!cd requests && git status
On branch main
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)

Untracked files:
  (use "git add <file>..." to include in what will be committed)

Changes not staged for commit (use "git add" and/or "git commit -a")
!cd requests && git diff
diff --git a/ b/
index f8f9429..502e33a 100644
--- a/
+++ b/
@@ -118,7 +118,7 @@ from .__version__ import __copyright__, __cake__
 from . import utils
 from . import packages
 from .models import Request, Response, PreparedRequest
-from .api import request, get, head, post, patch, put, delete, options
+from .api_v1 import request, get, head, post, patch, put, delete, options
 from .sessions import session, Session
 from .status_codes import codes
 from .exceptions import (

With, the file requests/ has been changed to import from new_api instead of api.

Rope can be used not only for renaming files, but also in various other cases; see also Rope Refactorings.