Skip to content

Commit

Permalink
restore files from master
Browse files Browse the repository at this point in the history
  • Loading branch information
bagel897 committed Feb 1, 2024
1 parent f2fd9e6 commit 97cfe93
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 71 deletions.
6 changes: 3 additions & 3 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ Additionally, you can run an executable function at startup of rope.
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 of the pyproject.toml.
It follows the exact same syntax as ``pyproject.toml``.

- Mac OS X: ``~/Library/Application Support/pytool.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
=======
-------
.. autopytoolconfigtable:: rope.base.prefs.Prefs

Autoimport Options
Expand Down
97 changes: 33 additions & 64 deletions rope/base/prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
@dataclass
class AutoimportPrefs:
underlined: bool = field(
default=False, description="Cache underlined (private) modules"
)
default=False, description="Cache underlined (private) modules")
# memory: bool = field(default=None, description="Cache in memory instead of disk")
# parallel: bool = field(default=True, description="Use multiple processes to parse")

aliases: List[Tuple[str, str]] = field(
default_factory=lambda: [
("np", "numpy"),
Expand All @@ -29,12 +29,10 @@ class AutoimportPrefs:
("sk", "sklearn"),
("sm", "statsmodels"),
],
description=dedent(
"""
description=dedent("""
Aliases for module names. For example, `[('np', 'numpy')]` makes rope recommend
``import numpy as np``.
"""
),
"""),
)


Expand All @@ -57,8 +55,7 @@ class Prefs:
".mypy_cache",
".pytest_cache",
],
description=dedent(
"""
description=dedent("""
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()`.
Expand All @@ -68,23 +65,19 @@ class Prefs:
'.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'
"""
),
"""),
)
python_files: List[str] = field(
default_factory=lambda: ["*.py"],
description=dedent(
"""
description=dedent("""
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.
"""
),
"""),
)
source_folders: List[str] = field(
description=dedent(
"""
description=dedent("""
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
Expand All @@ -93,8 +86,7 @@ class Prefs:
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.
"""
),
"""),
default_factory=lambda: [],
)
python_path: List[str] = field(
Expand All @@ -116,12 +108,10 @@ class Prefs:
)
perform_doa: bool = field(
default=True,
description=dedent(
"""
description=dedent("""
If `False` when running modules or unit tests 'dynamic object analysis' is turned off.
This makes them much faster.
"""
),
"""),
)
validate_objectdb: bool = field(
default=False,
Expand All @@ -139,13 +129,11 @@ class Prefs:

indent_size: int = field(
default=4,
description=dedent(
"""
description=dedent("""
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.
"""
),
"""),
)

extension_modules: List[str] = field(
Expand All @@ -161,86 +149,70 @@ class Prefs:
)
ignore_syntax_errors: bool = field(
default=False,
description=dedent(
"""
description=dedent("""
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.
"""
),
"""),
)

ignore_bad_imports: bool = field(
default=False,
description=dedent(
"""
description=dedent("""
If `True`, rope ignores unresolvable imports. Otherwise, they
appear in the importing namespace.
"""
),
"""),
)
prefer_module_from_imports: bool = field(
default=False,
description=dedent(
"""
description=dedent("""
If `True`, rope will insert new module imports as `from <package> import <module>`by default.
"""
),
"""),
)

split_imports: bool = field(
default=False,
description=dedent(
"""
description=dedent("""
If `True`, rope will transform a comma list of imports into
multiple separate import statements when organizing
imports.
"""
),
"""),
)

pull_imports_to_top: bool = field(
default=True,
description=dedent(
"""
description=dedent("""
If `True`, rope will remove all top-level import statements and
reinsert them at the top of the module when making changes.
"""
),
"""),
)

sort_imports_alphabetically: bool = field(
default=False,
description=dedent(
"""
description=dedent("""
If `True`, rope will sort imports alphabetically by module name instead
of alphabetically by import statement, with from imports after normal
imports.
"""
),
"""),
)
type_hinting_factory: str = field(
"rope.base.oi.type_hinting.factory.default_type_hinting_factory",
description=dedent(
"""
description=dedent("""
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.
"""
),
"""),
)
project_opened: Optional[Callable] = field(
None,
description=dedent(
"""
description=dedent("""
This function is called after opening the project.
Can only be set in config.py.
"""
),
"""),
)
py_version: Optional[Tuple[int, int]] = field(
default=None,
Expand All @@ -252,16 +224,13 @@ class Prefs:
)
callbacks: Dict[str, Callable[[Any], None]] = field(
default_factory=lambda: {},
description=dedent(
"""
description=dedent("""
Callbacks run when configuration values are changed.
Can only be set in config.py.
"""
),
"""),
)
autoimport: AutoimportPrefs = field(
default_factory=AutoimportPrefs, description="Preferences for Autoimport"
)
default_factory=AutoimportPrefs, description="Preferences for Autoimport")

def set(self, key: str, value: Any):
"""Set the value of `key` preference to `value`."""
Expand Down
9 changes: 5 additions & 4 deletions rope/contrib/autoimport/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,31 @@

import contextlib
import json
from hashlib import sha256
import secrets
import re
import secrets
import sqlite3
import sys
import warnings
from collections import OrderedDict
from concurrent.futures import Future, ProcessPoolExecutor, as_completed
from copy import deepcopy
from datetime import datetime
from hashlib import sha256
from itertools import chain
from pathlib import Path
from threading import local
from typing import Generator, Iterable, Iterator, List, Optional, Set, Tuple

from packaging.requirements import Requirement
from copy import deepcopy

from rope.base import exceptions, libutils, resourceobserver, taskhandle, versioning
from rope.base.prefs import AutoimportPrefs
from rope.base.project import Project
from rope.base.resources import Resource
from rope.contrib.autoimport import models
from rope.contrib.autoimport.defs import (
ModuleFile,
Alias,
ModuleFile,
Name,
NameType,
Package,
Expand Down

0 comments on commit 97cfe93

Please sign in to comment.