forked from VimPlug/jedi
Merge branch 'master' into mypy
This commit is contained in:
@@ -50,7 +50,7 @@ from jedi.inference.utils import to_list
|
||||
sys.setrecursionlimit(3000)
|
||||
|
||||
|
||||
class Script(object):
|
||||
class Script:
|
||||
"""
|
||||
A Script is the base for completions, goto or whatever you want to do with
|
||||
Jedi. The counter part of this class is :class:`Interpreter`, which works
|
||||
|
||||
@@ -54,7 +54,7 @@ def _values_to_definitions(values):
|
||||
return [Name(c.inference_state, c.name) for c in values]
|
||||
|
||||
|
||||
class BaseName(object):
|
||||
class BaseName:
|
||||
"""
|
||||
The base class for all definitions, completions and signatures.
|
||||
"""
|
||||
|
||||
@@ -30,7 +30,7 @@ class InvalidPythonEnvironment(Exception):
|
||||
"""
|
||||
|
||||
|
||||
class _BaseEnvironment(object):
|
||||
class _BaseEnvironment:
|
||||
@memoize_method
|
||||
def get_grammar(self):
|
||||
version_string = '%s.%s' % (self.version_info.major, self.version_info.minor)
|
||||
@@ -121,7 +121,7 @@ class Environment(_BaseEnvironment):
|
||||
return self._get_subprocess().get_sys_path()
|
||||
|
||||
|
||||
class _SameEnvironmentMixin(object):
|
||||
class _SameEnvironmentMixin:
|
||||
def __init__(self):
|
||||
self._start_executable = self.executable = sys.executable
|
||||
self.path = sys.prefix
|
||||
|
||||
@@ -8,7 +8,7 @@ def parso_to_jedi_errors(grammar, module_node):
|
||||
return [SyntaxError(e) for e in grammar.iter_errors(module_node)]
|
||||
|
||||
|
||||
class SyntaxError(object):
|
||||
class SyntaxError:
|
||||
"""
|
||||
Syntax errors are generated by :meth:`.Script.get_syntax_errors`.
|
||||
"""
|
||||
|
||||
@@ -203,7 +203,7 @@ def filter_follow_imports(names, follow_builtin_imports=False):
|
||||
yield name
|
||||
|
||||
|
||||
class CallDetails(object):
|
||||
class CallDetails:
|
||||
def __init__(self, bracket_leaf, children, position):
|
||||
['bracket_leaf', 'call_index', 'keyword_name_str']
|
||||
self.bracket_leaf = bracket_leaf
|
||||
|
||||
@@ -17,7 +17,7 @@ def _create(inference_state, obj):
|
||||
)
|
||||
|
||||
|
||||
class NamespaceObject(object):
|
||||
class NamespaceObject:
|
||||
def __init__(self, dct):
|
||||
self.__dict__ = dct
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ def _remove_duplicates_from_path(path):
|
||||
yield p
|
||||
|
||||
|
||||
class Project(object):
|
||||
class Project:
|
||||
"""
|
||||
Projects are a simple way to manage Python folders and define how Jedi does
|
||||
import resolution. It is mostly used as a parameter to :class:`.Script`.
|
||||
|
||||
@@ -12,7 +12,7 @@ EXPRESSION_PARTS = (
|
||||
).split()
|
||||
|
||||
|
||||
class ChangedFile(object):
|
||||
class ChangedFile:
|
||||
def __init__(self, inference_state, from_path, to_path,
|
||||
module_node, node_to_str_map):
|
||||
self._inference_state = inference_state
|
||||
@@ -72,7 +72,7 @@ class ChangedFile(object):
|
||||
return '<%s: %s>' % (self.__class__.__name__, self._from_path)
|
||||
|
||||
|
||||
class Refactoring(object):
|
||||
class Refactoring:
|
||||
def __init__(self, inference_state, file_to_node_changes, renames=()):
|
||||
self._inference_state = inference_state
|
||||
self._renames = renames
|
||||
|
||||
@@ -45,7 +45,7 @@ try:
|
||||
_inited = True
|
||||
|
||||
except ImportError:
|
||||
class Fore(object): # type: ignore[no-redef]
|
||||
class Fore: # type: ignore[no-redef]
|
||||
RED = ''
|
||||
GREEN = ''
|
||||
YELLOW = ''
|
||||
|
||||
@@ -3,7 +3,7 @@ import os
|
||||
from parso import file_io
|
||||
|
||||
|
||||
class AbstractFolderIO(object):
|
||||
class AbstractFolderIO:
|
||||
def __init__(self, path):
|
||||
self.path = path
|
||||
|
||||
@@ -57,7 +57,7 @@ class FolderIO(AbstractFolderIO):
|
||||
del dirs[i]
|
||||
|
||||
|
||||
class FileIOFolderMixin(object):
|
||||
class FileIOFolderMixin:
|
||||
def get_parent_folder(self):
|
||||
return FolderIO(os.path.dirname(self.path))
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ from jedi.inference.imports import follow_error_node_imports_if_possible
|
||||
from jedi.plugins import plugin_manager
|
||||
|
||||
|
||||
class InferenceState(object):
|
||||
class InferenceState:
|
||||
def __init__(self, project, environment=None, script_path=None):
|
||||
if environment is None:
|
||||
environment = project.get_environment()
|
||||
|
||||
@@ -26,7 +26,7 @@ CODES = {
|
||||
}
|
||||
|
||||
|
||||
class Error(object):
|
||||
class Error:
|
||||
def __init__(self, name, module_path, start_pos, message=None):
|
||||
self.path = module_path
|
||||
self._start_pos = start_pos
|
||||
|
||||
@@ -124,7 +124,7 @@ def _parse_argument_clinic(string):
|
||||
allow_kwargs = True
|
||||
|
||||
|
||||
class _AbstractArgumentsMixin(object):
|
||||
class _AbstractArgumentsMixin:
|
||||
def unpack(self, funcdef=None):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ from jedi.cache import memoize_method
|
||||
sentinel = object()
|
||||
|
||||
|
||||
class HelperValueMixin(object):
|
||||
class HelperValueMixin:
|
||||
def get_root_context(self):
|
||||
value = self
|
||||
if value.parent_context is None:
|
||||
@@ -363,7 +363,7 @@ class TreeValue(Value):
|
||||
return '<%s: %s>' % (self.__class__.__name__, self.tree_node)
|
||||
|
||||
|
||||
class ContextualizedNode(object):
|
||||
class ContextualizedNode:
|
||||
def __init__(self, context, node):
|
||||
self.context = context
|
||||
self.node = node
|
||||
@@ -405,7 +405,7 @@ def _getitem(value, index_values, contextualized_node):
|
||||
return result
|
||||
|
||||
|
||||
class ValueSet(object):
|
||||
class ValueSet:
|
||||
def __init__(self, iterable):
|
||||
self._set = frozenset(iterable)
|
||||
for value in iterable:
|
||||
|
||||
@@ -134,7 +134,7 @@ def load_module(inference_state, dotted_name, sys_path):
|
||||
return create_access_path(inference_state, module)
|
||||
|
||||
|
||||
class AccessPath(object):
|
||||
class AccessPath:
|
||||
def __init__(self, accesses):
|
||||
self.accesses = accesses
|
||||
|
||||
@@ -156,7 +156,7 @@ def get_api_type(obj):
|
||||
return 'instance'
|
||||
|
||||
|
||||
class DirectObjectAccess(object):
|
||||
class DirectObjectAccess:
|
||||
def __init__(self, inference_state, obj):
|
||||
self._inference_state = inference_state
|
||||
self._obj = obj
|
||||
|
||||
@@ -81,7 +81,7 @@ def _cleanup_process(process, thread):
|
||||
pass
|
||||
|
||||
|
||||
class _InferenceStateProcess(object):
|
||||
class _InferenceStateProcess:
|
||||
def __init__(self, inference_state):
|
||||
self._inference_state_weakref = weakref.ref(inference_state)
|
||||
self._inference_state_id = id(inference_state)
|
||||
@@ -162,7 +162,7 @@ class InferenceStateSubprocess(_InferenceStateProcess):
|
||||
self._compiled_subprocess.delete_inference_state(self._inference_state_id)
|
||||
|
||||
|
||||
class CompiledSubprocess(object):
|
||||
class CompiledSubprocess:
|
||||
is_crashed = False
|
||||
|
||||
def __init__(self, executable, env_vars=None):
|
||||
@@ -280,7 +280,7 @@ class CompiledSubprocess(object):
|
||||
self._inference_state_deletion_queue.append(inference_state_id)
|
||||
|
||||
|
||||
class Listener(object):
|
||||
class Listener:
|
||||
def __init__(self):
|
||||
self._inference_states = {}
|
||||
# TODO refactor so we don't need to process anymore just handle
|
||||
@@ -346,7 +346,7 @@ class Listener(object):
|
||||
pickle_dump(result, stdout, PICKLE_PROTOCOL)
|
||||
|
||||
|
||||
class AccessHandle(object):
|
||||
class AccessHandle:
|
||||
def __init__(self, subprocess, access, id_):
|
||||
self.access = access
|
||||
self._subprocess = subprocess
|
||||
|
||||
@@ -229,7 +229,7 @@ def _get_source(loader, fullname):
|
||||
name=fullname)
|
||||
|
||||
|
||||
class ImplicitNSInfo(object):
|
||||
class ImplicitNSInfo:
|
||||
"""Stores information returned from an implicit namespace spec"""
|
||||
def __init__(self, name, paths):
|
||||
self.name = name
|
||||
|
||||
@@ -22,7 +22,7 @@ from jedi.inference.signature import BuiltinSignature
|
||||
from jedi.inference.context import CompiledContext, CompiledModuleContext
|
||||
|
||||
|
||||
class CheckAttribute(object):
|
||||
class CheckAttribute:
|
||||
"""Raises :exc:`AttributeError` if the attribute X is not available."""
|
||||
def __init__(self, check_name=None):
|
||||
# Remove the py in front of e.g. py__call__.
|
||||
|
||||
@@ -13,7 +13,7 @@ from jedi import debug
|
||||
from jedi import parser_utils
|
||||
|
||||
|
||||
class AbstractContext(object):
|
||||
class AbstractContext:
|
||||
# Must be defined: inference_state and tree_node and parent_context as an attribute/property
|
||||
|
||||
def __init__(self, inference_state):
|
||||
@@ -216,7 +216,7 @@ class ValueContext(AbstractContext):
|
||||
return '%s(%s)' % (self.__class__.__name__, self._value)
|
||||
|
||||
|
||||
class TreeContextMixin(object):
|
||||
class TreeContextMixin:
|
||||
def infer_node(self, node):
|
||||
from jedi.inference.syntax_tree import infer_node
|
||||
return infer_node(self, node)
|
||||
|
||||
@@ -21,7 +21,7 @@ _definition_name_cache: MutableMapping[UsedNamesMapping, List[Name]]
|
||||
_definition_name_cache = weakref.WeakKeyDictionary()
|
||||
|
||||
|
||||
class AbstractFilter(object):
|
||||
class AbstractFilter:
|
||||
_until_position = None
|
||||
|
||||
def _filter(self, names):
|
||||
@@ -38,7 +38,7 @@ class AbstractFilter(object):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class FilterWrapper(object):
|
||||
class FilterWrapper:
|
||||
name_wrapper_class: Type[NameWrapper]
|
||||
|
||||
def __init__(self, wrapped_filter):
|
||||
@@ -232,7 +232,7 @@ class DictFilter(AbstractFilter):
|
||||
return '<%s: for {%s}>' % (self.__class__.__name__, keys)
|
||||
|
||||
|
||||
class MergedFilter(object):
|
||||
class MergedFilter:
|
||||
def __init__(self, *filters):
|
||||
self._filters = filters
|
||||
|
||||
@@ -323,7 +323,7 @@ class _OverwriteMeta(type):
|
||||
cls.overwritten_methods = base_dct
|
||||
|
||||
|
||||
class _AttributeOverwriteMixin(object):
|
||||
class _AttributeOverwriteMixin:
|
||||
def get_filters(self, *args, **kwargs):
|
||||
yield SpecialMethodFilter(self, self.overwritten_methods, self._wrapped_value)
|
||||
yield from self._wrapped_value.get_filters(*args, **kwargs)
|
||||
|
||||
@@ -5,7 +5,7 @@ from jedi.inference.recursion import execution_allowed
|
||||
from jedi.inference.helpers import is_big_annoying_library
|
||||
|
||||
|
||||
class Status(object):
|
||||
class Status:
|
||||
lookup_table: Dict[Optional[bool], 'Status'] = {}
|
||||
|
||||
def __init__(self, value: Optional[bool], name: str) -> None:
|
||||
|
||||
@@ -37,7 +37,7 @@ class _BoundTypeVarName(AbstractNameDefinition):
|
||||
return '<%s %s -> %s>' % (self.__class__.__name__, self.py__name__(), self._value_set)
|
||||
|
||||
|
||||
class _TypeVarFilter(object):
|
||||
class _TypeVarFilter:
|
||||
"""
|
||||
A filter for all given variables in a class.
|
||||
|
||||
@@ -246,7 +246,7 @@ class GenericClass(DefineGenericBaseClass, ClassMixin):
|
||||
return type_var_dict
|
||||
|
||||
|
||||
class _LazyGenericBaseClass(object):
|
||||
class _LazyGenericBaseClass:
|
||||
def __init__(self, class_value, lazy_base_class, generics_manager):
|
||||
self._class_value = class_value
|
||||
self._lazy_base_class = lazy_base_class
|
||||
|
||||
@@ -23,7 +23,7 @@ def _resolve_forward_references(context, value_set):
|
||||
yield value
|
||||
|
||||
|
||||
class _AbstractGenericManager(object):
|
||||
class _AbstractGenericManager:
|
||||
def get_index_and_execute(self, index):
|
||||
try:
|
||||
return self[index].execute_annotation()
|
||||
|
||||
@@ -32,7 +32,7 @@ from jedi.inference.compiled.subprocess.functions import ImplicitNSInfo
|
||||
from jedi.plugins import plugin_manager
|
||||
|
||||
|
||||
class ModuleCache(object):
|
||||
class ModuleCache:
|
||||
def __init__(self):
|
||||
self._name_cache = {}
|
||||
|
||||
@@ -150,7 +150,7 @@ def _level_to_base_import_path(project_path, directory, level):
|
||||
return None, directory
|
||||
|
||||
|
||||
class Importer(object):
|
||||
class Importer:
|
||||
def __init__(self, inference_state, import_path, module_context, level=0):
|
||||
"""
|
||||
An implementation similar to ``__import__``. Use `follow`
|
||||
|
||||
@@ -2,7 +2,7 @@ from jedi.inference.base_value import ValueSet, NO_VALUES
|
||||
from jedi.common import monkeypatch
|
||||
|
||||
|
||||
class AbstractLazyValue(object):
|
||||
class AbstractLazyValue:
|
||||
def __init__(self, data, min=1, max=1):
|
||||
self.data = data
|
||||
self.min = min
|
||||
|
||||
@@ -24,7 +24,7 @@ def _merge_name_docs(names):
|
||||
return doc
|
||||
|
||||
|
||||
class AbstractNameDefinition(object):
|
||||
class AbstractNameDefinition:
|
||||
start_pos: Optional[Tuple[int, int]] = None
|
||||
string_name: str
|
||||
parent_context = None
|
||||
@@ -224,7 +224,7 @@ class AbstractTreeName(AbstractNameDefinition):
|
||||
return self.tree_name.start_pos
|
||||
|
||||
|
||||
class ValueNameMixin(object):
|
||||
class ValueNameMixin:
|
||||
def infer(self):
|
||||
return ValueSet([self._value])
|
||||
|
||||
@@ -347,7 +347,7 @@ class TreeNameDefinition(AbstractTreeName):
|
||||
return ''
|
||||
|
||||
|
||||
class _ParamMixin(object):
|
||||
class _ParamMixin:
|
||||
def maybe_positional_argument(self, include_star=True):
|
||||
options = [Parameter.POSITIONAL_ONLY, Parameter.POSITIONAL_OR_KEYWORD]
|
||||
if include_star:
|
||||
@@ -605,7 +605,7 @@ class SubModuleName(ImportName):
|
||||
_level = 1
|
||||
|
||||
|
||||
class NameWrapper(object):
|
||||
class NameWrapper:
|
||||
def __init__(self, wrapped_name):
|
||||
self._wrapped_name = wrapped_name
|
||||
|
||||
@@ -616,7 +616,7 @@ class NameWrapper(object):
|
||||
return '%s(%s)' % (self.__class__.__name__, self._wrapped_name)
|
||||
|
||||
|
||||
class StubNameMixin(object):
|
||||
class StubNameMixin:
|
||||
def py__doc__(self):
|
||||
from jedi.inference.gradual.conversion import convert_names
|
||||
# Stubs are not complicated and we can just follow simple statements
|
||||
|
||||
@@ -50,7 +50,7 @@ A function may not be executed more than this number of times recursively.
|
||||
"""
|
||||
|
||||
|
||||
class RecursionDetector(object):
|
||||
class RecursionDetector:
|
||||
def __init__(self):
|
||||
self.pushed_nodes = []
|
||||
|
||||
@@ -92,7 +92,7 @@ def execution_recursion_decorator(default=NO_VALUES):
|
||||
return decorator
|
||||
|
||||
|
||||
class ExecutionRecursionDetector(object):
|
||||
class ExecutionRecursionDetector:
|
||||
"""
|
||||
Catches recursions of executions.
|
||||
"""
|
||||
|
||||
@@ -5,7 +5,7 @@ from jedi import debug
|
||||
from jedi import parser_utils
|
||||
|
||||
|
||||
class _SignatureMixin(object):
|
||||
class _SignatureMixin:
|
||||
def to_string(self):
|
||||
def param_strings():
|
||||
is_positional = False
|
||||
|
||||
@@ -70,7 +70,7 @@ def reraise_uncaught(func):
|
||||
return wrapper
|
||||
|
||||
|
||||
class PushBackIterator(object):
|
||||
class PushBackIterator:
|
||||
def __init__(self, iterator):
|
||||
self.pushes = []
|
||||
self.iterator = iterator
|
||||
|
||||
@@ -53,7 +53,7 @@ class FunctionAndClassBase(TreeValue):
|
||||
return None
|
||||
|
||||
|
||||
class FunctionMixin(object):
|
||||
class FunctionMixin:
|
||||
api_type = 'function'
|
||||
|
||||
def get_filters(self, origin_scope=None):
|
||||
|
||||
@@ -19,7 +19,7 @@ from jedi.inference.context import CompForContext
|
||||
from jedi.inference.value.dynamic_arrays import check_array_additions
|
||||
|
||||
|
||||
class IterableMixin(object):
|
||||
class IterableMixin:
|
||||
def py__next__(self, contextualized_node=None):
|
||||
return self.py__iter__(contextualized_node)
|
||||
|
||||
@@ -127,7 +127,7 @@ def comprehension_from_atom(inference_state, value, atom):
|
||||
)
|
||||
|
||||
|
||||
class ComprehensionMixin(object):
|
||||
class ComprehensionMixin:
|
||||
@inference_state_method_cache()
|
||||
def _get_comp_for_context(self, parent_context, comp_for):
|
||||
return CompForContext(parent_context, comp_for)
|
||||
@@ -175,7 +175,7 @@ class ComprehensionMixin(object):
|
||||
return "<%s of %s>" % (type(self).__name__, self._sync_comp_for_node)
|
||||
|
||||
|
||||
class _DictMixin(object):
|
||||
class _DictMixin:
|
||||
def _get_generics(self):
|
||||
return tuple(c_set.py__class__() for c_set in self.get_mapping_item_values())
|
||||
|
||||
@@ -247,7 +247,7 @@ class GeneratorComprehension(_BaseComprehension, GeneratorBase):
|
||||
pass
|
||||
|
||||
|
||||
class _DictKeyMixin(object):
|
||||
class _DictKeyMixin:
|
||||
# TODO merge with _DictMixin?
|
||||
def get_mapping_item_values(self):
|
||||
return self._dict_keys(), self._dict_values()
|
||||
|
||||
@@ -142,7 +142,7 @@ class ClassFilter(ParserTreeFilter):
|
||||
return [name for name in names if self._access_possible(name)]
|
||||
|
||||
|
||||
class ClassMixin(object):
|
||||
class ClassMixin:
|
||||
def is_class(self):
|
||||
return True
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class _ModuleAttributeName(AbstractNameDefinition):
|
||||
return compiled.get_string_value_set(self.parent_context.inference_state)
|
||||
|
||||
|
||||
class SubModuleDictMixin(object):
|
||||
class SubModuleDictMixin:
|
||||
@inference_state_method_cache()
|
||||
def sub_modules_dict(self):
|
||||
"""
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from functools import wraps
|
||||
|
||||
|
||||
class _PluginManager(object):
|
||||
class _PluginManager:
|
||||
def __init__(self):
|
||||
self._registered_plugins = []
|
||||
self._cached_base_callbacks = {}
|
||||
|
||||
@@ -65,7 +65,7 @@ def setup_readline(namespace_module=__main__, fuzzy=False):
|
||||
level=logging.DEBUG
|
||||
)
|
||||
|
||||
class JediRL(object):
|
||||
class JediRL:
|
||||
def complete(self, text, state):
|
||||
"""
|
||||
This complete stuff is pretty weird, a generator would make
|
||||
|
||||
Reference in New Issue
Block a user