rope.contrib.autoimport.sqlite
AutoImport module for rope.
Classes
A class for finding the module that provides a name. |
Functions
|
Get all names as futures. |
|
Filter list of packages to parse. |
Module Contents
- rope.contrib.autoimport.sqlite.get_future_names(packages: List[rope.contrib.autoimport.defs.Package], underlined: bool, job_set: rope.base.taskhandle.BaseJobSet) Generator[concurrent.futures.Future[collections.abc.Collection[rope.contrib.autoimport.defs.Name]], None, None]
Get all names as futures.
- rope.contrib.autoimport.sqlite.filter_packages(packages: Iterable[rope.contrib.autoimport.defs.Package], underlined: bool, existing: List[str]) Iterable[rope.contrib.autoimport.defs.Package]
Filter list of packages to parse.
- class rope.contrib.autoimport.sqlite.AutoImport(project: rope.base.project.Project, observe: bool = True, underlined: bool = False, memory: bool = _deprecated_default)
A class for finding the module that provides a name.
This class maintains a cache of global names in python modules. Note that this cache is not accurate and might be out of date.
- project: rope.base.project.Project
- project_package: rope.contrib.autoimport.defs.Package
- thread_local
- property connection: sqlite3.Connection
Creates a new connection if called from a new thread.
This makes sure AutoImport can be shared across threads.
- classmethod create_database_connection(*, project: rope.base.project.Project | None = None, memory: bool = False) sqlite3.Connection
Create an sqlite3 connection
- projectrope.base.project.Project
the project to use for project imports
- memorybool
if true, don’t persist to disk
- import_assist(starting: str)
Find modules that have a global name that starts with starting.
For a more complete list, use the search or search_full methods.
- Parameters:
starting (str) – what all the names should start with
- Return type:
Return a list of
(name, module)tuples
- search(name: str, exact_match: bool = False) List[Tuple[str, str]]
Search both modules and names for an import string.
This is a simple wrapper around search_full with basic sorting based on Source.
Returns a sorted list of import statement, modname pairs
- search_full(name: str, exact_match: bool = False, ignored_names: Set[str] | None = None) Generator[rope.contrib.autoimport.defs.SearchResult, None, None]
Search both modules and names for an import string.
- Parameters:
- Return type:
Unsorted Generator of SearchResults. Each is guaranteed to be unique.
- generate_cache(resources: List[rope.base.resources.Resource] | None = None, underlined: bool = False, task_handle: rope.base.taskhandle.BaseTaskHandle = taskhandle.DEFAULT_TASK_HANDLE)
Generate global name cache for project files.
If resources is a list of rope.base.resource.File, only those files are searched; otherwise all python modules in the project are cached.
- generate_modules_cache(modules: List[str] | None = None, task_handle: rope.base.taskhandle.BaseTaskHandle = taskhandle.DEFAULT_TASK_HANDLE, single_thread: bool = False, underlined: bool | None = None)
Generate global name cache for external modules listed in modules.
If no modules are provided, it will generate a cache for every module available. This method searches in your sys.path and configured python folders. Do not use this for generating your own project’s internal names, use generate_resource_cache for that instead.
- close()
Close the autoimport database.
- get_name_locations(name)
Return a list of
(resource, lineno)tuples.
- clear_cache()
Clear all entries in global-name cache.
It might be a good idea to use this function before regenerating global names.
- find_insertion_line(code)
Guess at what line the new import should be inserted.
- update_resource(resource: rope.base.resources.Resource, underlined: bool = False, commit: bool = True)
Update the cache for global names in resource.
- add_aliases(aliases: collections.abc.Collection[rope.contrib.autoimport.defs.Alias])