Registry / testing / rope
library1.14.0pypypi✓ verified 25d ago

Rope is an advanced, open-source Python refactoring library. It provides extensive APIs for performing various code transformations like renaming, extracting methods, and moving elements. Actively maintained, it sees regular updates with recent releases like 1.14.0, and supports modern Python versions.

pip install rope
INSTALL
IMPORT
SIG · ROPE
R
rope
testingpythonv1.14.0
Install
2.0s avg
Import
356ms
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.14.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.372s · 21.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.0s · import 0.340s · 22MB
20MB installed
● package 20MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Project
from rope.base.project import Project
Used to manage the codebase and its files for refactoring operations.
File
from rope.base.resources import File
Represents a Python file within a Rope project. `Resource` is the base class for files and folders.
Rename
from rope.refactor.rename import Rename
One of many refactoring classes provided by Rope.

This example demonstrates how to initialize a Rope project, load a Python file, and perform a simple variable renaming refactoring. It creates a temporary file and directory, renames a variable 'old_name' to 'new_name', applies the changes, and then cleans up. The `Project` object manages the codebase, `Resource` objects represent files, and specific refactoring classes (like `Rename`) perform transformations.

import os import tempfile import shutil from pathlib import Path from rope.base.project import Project from rope.base.resources import File from rope.refactor.rename import Rename # Create a temporary directory and a dummy Python file temp_dir = Path(tempfile.mkdtemp()) file_path = temp_dir / "my_module.py" file_path.write_text(""" def greet(): old_name = "World" print(f"Hello, {old_name}!") """) project = Project(temp_dir) resource = project.get_resource(file_path.name) # Find the start offset of 'old_name' # In ' old_name = "World"', 'old_name' starts at index 5 offset = file_path.read_text().find('old_name = "World"') + 4 # Perform rename refactoring changes = Rename(project, resource, offset).get_changes('new_name') # Apply the changes to the project files project.do(changes) # Verify the change print(file_path.read_text()) # Clean up project.close() shutil.rmtree(temp_dir)
Debug
Known issues
breakingRope versions 1.0.0 and above no longer support Python 2. Users requiring Python 2 compatibility must use 0.x.x releases or the `python2` branch.
fix
Upgrade to Python 3.8+ or use older Rope versions for Python 2 projects.
affects: >=1.0.0
gotchaBy default, Rope creates a `.ropeproject` folder in the project root to store configuration and data (e.g., history, object information). This folder can be configured or disabled via the `ropefolder` parameter in the `Project` constructor.
fix
Be aware of the `.ropeproject` folder for project setup and consider configuring `ropefolder=None` if not desired, or adding it to version control ignore files.
affects: All versions
gotchaAs of version 1.12.0, Rope no longer includes `site-packages` in its default search tree for modules. This might affect auto-import suggestions or object inference for packages not explicitly within the defined project source folders.
fix
If needed, explicitly configure `python_path` in `config.py` or through the `Project` constructor to include paths to relevant external modules.
affects: >=1.12.0
gotchaVersion 1.13.0 introduced validation to prevent renaming a symbol to a Python keyword. While a safety enhancement, this changes previous behavior that might have allowed such renames (which would lead to syntax errors).
fix
Ensure new names for refactored symbols are not Python keywords.
affects: >=1.13.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'rope'
The 'rope' library is not installed in the Python environment where the code is being executed.
fix
Install the library using pip: `pip install rope`
rope.base.exceptions.ResourceNotFound: Path 'my_file.py' not found
Rope could not locate the specified file or resource within the project's scope, often because the path is incorrect or the file doesn't exist.
fix
Ensure the file exists and the path provided to `project.get_resource()` is correct and relative to the project root or absolute.
rope.base.exceptions.BadLocationError: Cannot rename here
The specified offset or text range for a refactoring operation (e.g., rename, extract method) does not correspond to a valid, refactorable code element.
fix
Adjust the `offset` and/or `selection` to accurately point to a valid code element that Rope can refactor, such as a variable name or a complete code block.
AttributeError: 'str' object has no attribute 'read_full_text'
A `rope` API method was called with an incorrect type of argument, such as a string representing a file path instead of a `rope.base.resources.File` object.
fix
Ensure arguments requiring a `Resource` object are first obtained from `project.get_resource()` rather than just passing a string path.
rope.base.exceptions.ResourceNotFound: Does not exist
The path provided to `project.get_resource()` does not correspond to an existing file or directory within the project's defined scope, or the project root itself is incorrect.
fix
Ensure the `project_root` for `rope.base.project.Project` is correctly set to an existing directory, and the `path` provided to `get_resource` is a valid, existing path relative to that `project_root`.
Upgrade
Version history
1.14.0latest on PyPI · released Jul 12, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Resources
rope — pip install rope · libregistry