Configuration

Rope supports the following configuration formats

  1. pyproject.toml

  2. config.py

  3. pytool.toml

pyproject.toml

Will be used if [tool.rope] is configured.

[tool.rope]
split_imports = true
autoimport.aliases = [
    ['dt', 'datetime'],
    ['mp', 'multiprocessing'],
]

config.py

You can also configure rope via a config.py in the ropefolder directory. It will be used if [tool.rope] is not present in pyproject.toml or pyproject.toml isn’t present and config.py is present.

def set_prefs(prefs):
    prefs["ignored_resources"] = [
        "*.pyc",
        "*~",
        ".ropeproject",
        ".hg",
        ".svn",
        "_svn",
        ".git",
        ".tox",
        ".venv",
        "venv",
    ]

Additionally, you can run an executable function at startup of rope.

def project_opened(project):
    """This function is called after opening the project"""
    # Do whatever you like here!

pytool.toml

If neither a config.py or a pyproject.toml is present, rope will use a pytool.toml. It follows the exact same syntax as pyproject.toml.

  • Mac OS X: ~/Library/Application Support/pytool.toml.

  • Unix: ~/.config/pytool.toml` or in $XDG_CONFIG_HOME, if defined

  • Windows: C:\Users\<username>\AppData\Local\pytool.toml

Options

name

description

type

default

ignored_resources

Specify which files and folders to ignore in the project. Changes to ignored resources are not added to the history and VCSs. Also they are not returned in Project.get_files(). Note that ? and * match all characters but slashes. *.pyc: matches test.pyc and pkg/test.pyc mod*.pyc: matches test/mod1.pyc but not mod/1.pyc .svn: matches pkg/.svn and all of its children build/*.o: matches build/lib.o but not build/sub/lib.o build//*.o: matches build/lib.o and build/sub/lib.o

List[str]

[’*.pyc’, ‘*~’, ‘.ropeproject’, ‘.hg’, ‘.svn’, ‘_svn’, ‘.git’, ‘.tox’, ‘.venv’, ‘venv’, ‘.mypy_cache’, ‘.pytest_cache’]

python_files

Specifies which files should be considered python files. It is useful when you have scripts inside your project. Only files ending with .py are considered to be python files by default.

List[str]

[’*.py’]

source_folders

Custom source folders: By default rope searches the project for finding source folders (folders that should be searched for finding modules). You can add paths to that list. Note that rope guesses project source folders correctly most of the time; use this if you have any problems. The folders should be relative to project root and use / for separating folders regardless of the platform rope is running on. src/my_source_folder for instance.

List[str]

[]

python_path

You can extend python path for looking up modules.

List[str]

[]

save_objectdb

Should rope save object information or not.

bool

False

compress_objectdb

Deprecated. This has no effect

bool

False

automatic_soa

If True, rope analyzes each module when it is being saved.

bool

True

soa_followed_calls

The depth of calls to follow in static object analysis

int

0

perform_doa

If False when running modules or unit tests ‘dynamic object analysis’ is turned off. This makes them much faster.

bool

True

validate_objectdb

Rope can check the validity of its object DB when running.

bool

False

max_history_items

How many undos to hold?

int

32

save_history

Shows whether to save history across sessions.

bool

True

compress_history

Deprecated. This has no effect

bool

False

indent_size

Set the number spaces used for indenting. According to PEP 8, it is best to use 4 spaces. Since most of rope’s unit-tests use 4 spaces it is more reliable, too.

int

4

extension_modules

Builtin and c-extension modules that are allowed to be imported and inspected by rope.

List[str]

[]

import_dynload_stdmods

Add all standard c-extensions to extension_modules list.

bool

True

ignore_syntax_errors

If True modules with syntax errors are considered to be empty. The default value is False; When False syntax errors raise rope.base.exceptions.ModuleSyntaxError exception.

bool

False

ignore_bad_imports

If True, rope ignores unresolvable imports. Otherwise, they appear in the importing namespace.

bool

False

prefer_module_from_imports

If True, rope will insert new module imports as from <package> import <module> by default.

bool

False

split_imports

If True, rope will transform a comma list of imports into multiple separate import statements when organizing imports.

bool

False

pull_imports_to_top

If True, rope will remove all top-level import statements and reinsert them at the top of the module when making changes.

bool

True

sort_imports_alphabetically

If True, rope will sort imports alphabetically by module name instead of alphabetically by import statement, with from imports after normal imports.

bool

False

type_hinting_factory

Location of implementation of rope.base.oi.type_hinting.interfaces.ITypeHintingFactory In general case, you don’t have to change this value, unless you’re an rope expert. Change this value to inject you own implementations of interfaces listed in module rope.base.oi.type_hinting.providers.interfaces For example, you can add you own providers for Django Models, or disable the search type-hinting in a class hierarchy, etc.

str

rope.base.oi.type_hinting.factory.default_type_hinting_factory

project_opened

This function is called after opening the project. Can only be set in config.py.

Optional[Callable]

py_version

Minimum target python version. Requires PEP 621.

Taken from project.requires-python

Optional[Tuple[int, int]]

dependencies

Dependencies of project. Requires PEP 621.

Taken from project.dependencies.

Optional[List[packaging.requirements.Requirement]]

callbacks

Callbacks run when configuration values are changed. Can only be set in config.py.

Dict[str, Callable[[Any], NoneType]]

{}

autoimport.* Options

name

description

type

default

aliases

Aliases for module names. For example, [(‘np’, ‘numpy’)] makes rope recommend import numpy as np.

List[Tuple[str, str]]

[(‘np’, ‘numpy’), (‘pd’, ‘pandas’), (‘plt’, ‘matplotlib.pyplot’), (‘sns’, ‘seaborn’), (‘tf’, ‘tensorflow’), (‘sk’, ‘sklearn’), (‘sm’, ‘statsmodels’)]

Old Configuration File

This is a sample config.py. While this config.py works and all options here should be supported, the above documentation reflects the recommended way to do configuration in the latest version of rope.

# The default ``config.py``
# flake8: noqa


def set_prefs(prefs):
    """This function is called before opening the project"""

    # Specify which files and folders to ignore in the project.
    # Changes to ignored resources are not added to the history and
    # VCSs.  Also they are not returned in `Project.get_files()`.
    # Note that ``?`` and ``*`` match all characters but slashes.
    # "*.pyc": matches "test.pyc" and "pkg/test.pyc"
    # "mod*.pyc": matches "test/mod1.pyc" but not "mod/1.pyc"
    # ".svn": matches "pkg/.svn" and all of its children
    # "build/*.o": matches "build/lib.o" but not "build/sub/lib.o"
    # "build//*.o": matches "build/lib.o" and "build/sub/lib.o"
    #
    #    prefs["ignored_resources"] = [
    #        "*.pyc",
    #        "*~",
    #        ".ropeproject",
    #        ".hg",
    #        ".svn",
    #        "_svn",
    #        ".git",
    #        ".tox",
    #        ".venv",
    #        "venv",
    #        ".mypy_cache",
    #        ".pytest_cache",
    #    ]

    # Specifies which files should be considered python files.  It is
    # useful when you have scripts inside your project.  Only files
    # ending with ``.py`` are considered to be python files by
    # default.
    #
    #     prefs["python_files"] = ["*.py"]

    # Custom source folders:  By default rope searches the project
    # for finding source folders (folders that should be searched
    # for finding modules).  You can add paths to that list.  Note
    # that rope guesses project source folders correctly most of the
    # time; use this if you have any problems.
    # The folders should be relative to project root and use "/" for
    # separating folders regardless of the platform rope is running on.
    # "src/my_source_folder" for instance.
    #
    #     prefs.add("source_folders", "src")

    # You can extend python path for looking up modules
    #
    #     prefs.add("python_path", "~/python/")

    # Should rope save object information or not.
    #
    #     prefs["save_objectdb"] = True

    # If `True`, rope analyzes each module when it is being saved.
    #
    #     prefs["automatic_soa"] = True
    #
    # The depth of calls to follow in static object analysis
    #
    #     prefs["soa_followed_calls"] = 0

    # If `False` when running modules or unit tests "dynamic object
    # analysis" is turned off.  This makes them much faster.
    #
    #     prefs["perform_doa"] = True

    # Rope can check the validity of its object DB when running.
    #
    #    prefs["validate_objectdb"] = True

    # How many undos to hold?
    #
    #     prefs["max_history_items"] = 32

    # Shows whether to save history across sessions.
    #
    #     prefs["save_history"] = True

    # Set the number spaces used for indenting.  According to
    # :PEP:`8`, it is best to use 4 spaces.  Since most of rope's
    # unit-tests use 4 spaces it is more reliable, too.
    #
    #     prefs["indent_size"] = 4

    # Builtin and c-extension modules that are allowed to be imported
    # and inspected by rope.
    #
    #     prefs["extension_modules"] = []

    # Add all standard c-extensions to extension_modules list.
    #
    #     prefs["import_dynload_stdmods"] = True

    # If `True` modules with syntax errors are considered to be empty.
    # The default value is `False`; When `False` syntax errors raise
    # `rope.base.exceptions.ModuleSyntaxError` exception.
    #
    #     prefs["ignore_syntax_errors"] = False

    # If `True`, rope ignores unresolvable imports.  Otherwise, they
    # appear in the importing namespace.
    #
    #     prefs["ignore_bad_imports"] = False

    # If `True`, rope will insert new module imports as
    # `from <package> import <module>` by default.
    #
    #     prefs["prefer_module_from_imports"] = False

    # If `True`, rope will transform a comma list of imports into
    # multiple separate import statements when organizing
    # imports.
    #
    #     prefs["split_imports"] = False

    # If `True`, rope will remove all top-level import statements and
    # reinsert them at the top of the module when making changes.
    #
    #     prefs["pull_imports_to_top"] = True

    # If `True`, rope will sort imports alphabetically by module name instead
    # of alphabetically by import statement, with from imports after normal
    # imports.
    #
    #     prefs["sort_imports_alphabetically"] = False

    # Location of implementation of
    # rope.base.oi.type_hinting.interfaces.ITypeHintingFactory In general
    # case, you don't have to change this value, unless you're an rope expert.
    # Change this value to inject you own implementations of interfaces
    # listed in module rope.base.oi.type_hinting.providers.interfaces
    # For example, you can add you own providers for Django Models, or disable
    # the search type-hinting in a class hierarchy, etc.
    #
    #     prefs[
    #         "type_hinting_factory"
    #     ] = "rope.base.oi.type_hinting.factory.default_type_hinting_factory"


def project_opened(project):
    """This function is called after opening the project"""
    # Do whatever you like here!