Don't need to inherit from object anymore

This commit is contained in:
Dave Halter
2020-07-26 00:11:57 +02:00
parent e593396417
commit 9d1587a41d
36 changed files with 59 additions and 59 deletions

View File

@@ -50,7 +50,7 @@ from jedi.inference.utils import to_list
sys.setrecursionlimit(3000) sys.setrecursionlimit(3000)
class Script(object): class Script:
""" """
A Script is the base for completions, goto or whatever you want to do with 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 Jedi. The counter part of this class is :class:`Interpreter`, which works

View File

@@ -54,7 +54,7 @@ def _values_to_definitions(values):
return [Name(c.inference_state, c.name) for c in 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. The base class for all definitions, completions and signatures.
""" """

View File

@@ -30,7 +30,7 @@ class InvalidPythonEnvironment(Exception):
""" """
class _BaseEnvironment(object): class _BaseEnvironment:
@memoize_method @memoize_method
def get_grammar(self): def get_grammar(self):
version_string = '%s.%s' % (self.version_info.major, self.version_info.minor) 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() return self._get_subprocess().get_sys_path()
class _SameEnvironmentMixin(object): class _SameEnvironmentMixin:
def __init__(self): def __init__(self):
self._start_executable = self.executable = sys.executable self._start_executable = self.executable = sys.executable
self.path = sys.prefix self.path = sys.prefix

View File

@@ -8,7 +8,7 @@ def parso_to_jedi_errors(grammar, module_node):
return [SyntaxError(e) for e in grammar.iter_errors(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`. Syntax errors are generated by :meth:`.Script.get_syntax_errors`.
""" """

View File

@@ -203,7 +203,7 @@ def filter_follow_imports(names, follow_builtin_imports=False):
yield name yield name
class CallDetails(object): class CallDetails:
def __init__(self, bracket_leaf, children, position): def __init__(self, bracket_leaf, children, position):
['bracket_leaf', 'call_index', 'keyword_name_str'] ['bracket_leaf', 'call_index', 'keyword_name_str']
self.bracket_leaf = bracket_leaf self.bracket_leaf = bracket_leaf

View File

@@ -17,7 +17,7 @@ def _create(inference_state, obj):
) )
class NamespaceObject(object): class NamespaceObject:
def __init__(self, dct): def __init__(self, dct):
self.__dict__ = dct self.__dict__ = dct

View File

@@ -56,7 +56,7 @@ def _remove_duplicates_from_path(path):
yield p yield p
class Project(object): class Project:
""" """
Projects are a simple way to manage Python folders and define how Jedi does 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`. import resolution. It is mostly used as a parameter to :class:`.Script`.

View File

@@ -12,7 +12,7 @@ EXPRESSION_PARTS = (
).split() ).split()
class ChangedFile(object): class ChangedFile:
def __init__(self, inference_state, from_path, to_path, def __init__(self, inference_state, from_path, to_path,
module_node, node_to_str_map): module_node, node_to_str_map):
self._inference_state = inference_state self._inference_state = inference_state
@@ -72,7 +72,7 @@ class ChangedFile(object):
return '<%s: %s>' % (self.__class__.__name__, self._from_path) return '<%s: %s>' % (self.__class__.__name__, self._from_path)
class Refactoring(object): class Refactoring:
def __init__(self, inference_state, file_to_node_changes, renames=()): def __init__(self, inference_state, file_to_node_changes, renames=()):
self._inference_state = inference_state self._inference_state = inference_state
self._renames = renames self._renames = renames

View File

@@ -45,7 +45,7 @@ try:
_inited = True _inited = True
except ImportError: except ImportError:
class Fore(object): class Fore:
RED = '' RED = ''
GREEN = '' GREEN = ''
YELLOW = '' YELLOW = ''

View File

@@ -3,7 +3,7 @@ import os
from parso import file_io from parso import file_io
class AbstractFolderIO(object): class AbstractFolderIO:
def __init__(self, path): def __init__(self, path):
self.path = path self.path = path
@@ -57,7 +57,7 @@ class FolderIO(AbstractFolderIO):
del dirs[i] del dirs[i]
class FileIOFolderMixin(object): class FileIOFolderMixin:
def get_parent_folder(self): def get_parent_folder(self):
return FolderIO(os.path.dirname(self.path)) return FolderIO(os.path.dirname(self.path))

View File

@@ -81,7 +81,7 @@ from jedi.inference.imports import follow_error_node_imports_if_possible
from jedi.plugins import plugin_manager from jedi.plugins import plugin_manager
class InferenceState(object): class InferenceState:
def __init__(self, project, environment=None, script_path=None): def __init__(self, project, environment=None, script_path=None):
if environment is None: if environment is None:
environment = project.get_environment() environment = project.get_environment()

View File

@@ -26,7 +26,7 @@ CODES = {
} }
class Error(object): class Error:
def __init__(self, name, module_path, start_pos, message=None): def __init__(self, name, module_path, start_pos, message=None):
self.path = module_path self.path = module_path
self._start_pos = start_pos self._start_pos = start_pos

View File

@@ -124,7 +124,7 @@ def _parse_argument_clinic(string):
allow_kwargs = True allow_kwargs = True
class _AbstractArgumentsMixin(object): class _AbstractArgumentsMixin:
def unpack(self, funcdef=None): def unpack(self, funcdef=None):
raise NotImplementedError raise NotImplementedError

View File

@@ -22,7 +22,7 @@ from jedi.cache import memoize_method
sentinel = object() sentinel = object()
class HelperValueMixin(object): class HelperValueMixin:
def get_root_context(self): def get_root_context(self):
value = self value = self
if value.parent_context is None: if value.parent_context is None:
@@ -363,7 +363,7 @@ class TreeValue(Value):
return '<%s: %s>' % (self.__class__.__name__, self.tree_node) return '<%s: %s>' % (self.__class__.__name__, self.tree_node)
class ContextualizedNode(object): class ContextualizedNode:
def __init__(self, context, node): def __init__(self, context, node):
self.context = context self.context = context
self.node = node self.node = node
@@ -405,7 +405,7 @@ def _getitem(value, index_values, contextualized_node):
return result return result
class ValueSet(object): class ValueSet:
def __init__(self, iterable): def __init__(self, iterable):
self._set = frozenset(iterable) self._set = frozenset(iterable)
for value in iterable: for value in iterable:

View File

@@ -134,7 +134,7 @@ def load_module(inference_state, dotted_name, sys_path):
return create_access_path(inference_state, module) return create_access_path(inference_state, module)
class AccessPath(object): class AccessPath:
def __init__(self, accesses): def __init__(self, accesses):
self.accesses = accesses self.accesses = accesses
@@ -156,7 +156,7 @@ def get_api_type(obj):
return 'instance' return 'instance'
class DirectObjectAccess(object): class DirectObjectAccess:
def __init__(self, inference_state, obj): def __init__(self, inference_state, obj):
self._inference_state = inference_state self._inference_state = inference_state
self._obj = obj self._obj = obj

View File

@@ -81,7 +81,7 @@ def _cleanup_process(process, thread):
pass pass
class _InferenceStateProcess(object): class _InferenceStateProcess:
def __init__(self, inference_state): def __init__(self, inference_state):
self._inference_state_weakref = weakref.ref(inference_state) self._inference_state_weakref = weakref.ref(inference_state)
self._inference_state_id = id(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) self._compiled_subprocess.delete_inference_state(self._inference_state_id)
class CompiledSubprocess(object): class CompiledSubprocess:
is_crashed = False is_crashed = False
def __init__(self, executable, env_vars=None): def __init__(self, executable, env_vars=None):
@@ -280,7 +280,7 @@ class CompiledSubprocess(object):
self._inference_state_deletion_queue.append(inference_state_id) self._inference_state_deletion_queue.append(inference_state_id)
class Listener(object): class Listener:
def __init__(self): def __init__(self):
self._inference_states = {} self._inference_states = {}
# TODO refactor so we don't need to process anymore just handle # 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) pickle_dump(result, stdout, PICKLE_PROTOCOL)
class AccessHandle(object): class AccessHandle:
def __init__(self, subprocess, access, id_): def __init__(self, subprocess, access, id_):
self.access = access self.access = access
self._subprocess = subprocess self._subprocess = subprocess

View File

@@ -16,7 +16,7 @@ def _get_paths():
return {'jedi': _jedi_path, 'parso': _parso_path} return {'jedi': _jedi_path, 'parso': _parso_path}
class _ExactImporter(object): class _ExactImporter:
def __init__(self, path_dct): def __init__(self, path_dct):
self._path_dct = path_dct self._path_dct = path_dct

View File

@@ -229,7 +229,7 @@ def _get_source(loader, fullname):
name=fullname) name=fullname)
class ImplicitNSInfo(object): class ImplicitNSInfo:
"""Stores information returned from an implicit namespace spec""" """Stores information returned from an implicit namespace spec"""
def __init__(self, name, paths): def __init__(self, name, paths):
self.name = name self.name = name

View File

@@ -22,7 +22,7 @@ from jedi.inference.signature import BuiltinSignature
from jedi.inference.context import CompiledContext, CompiledModuleContext from jedi.inference.context import CompiledContext, CompiledModuleContext
class CheckAttribute(object): class CheckAttribute:
"""Raises :exc:`AttributeError` if the attribute X is not available.""" """Raises :exc:`AttributeError` if the attribute X is not available."""
def __init__(self, check_name=None): def __init__(self, check_name=None):
# Remove the py in front of e.g. py__call__. # Remove the py in front of e.g. py__call__.

View File

@@ -13,7 +13,7 @@ from jedi import debug
from jedi import parser_utils 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 # Must be defined: inference_state and tree_node and parent_context as an attribute/property
def __init__(self, inference_state): def __init__(self, inference_state):
@@ -216,7 +216,7 @@ class ValueContext(AbstractContext):
return '%s(%s)' % (self.__class__.__name__, self._value) return '%s(%s)' % (self.__class__.__name__, self._value)
class TreeContextMixin(object): class TreeContextMixin:
def infer_node(self, node): def infer_node(self, node):
from jedi.inference.syntax_tree import infer_node from jedi.inference.syntax_tree import infer_node
return infer_node(self, node) return infer_node(self, node)

View File

@@ -18,7 +18,7 @@ from jedi.inference.names import TreeNameDefinition, ParamName, \
_definition_name_cache = weakref.WeakKeyDictionary() _definition_name_cache = weakref.WeakKeyDictionary()
class AbstractFilter(object): class AbstractFilter:
_until_position = None _until_position = None
def _filter(self, names): def _filter(self, names):
@@ -35,7 +35,7 @@ class AbstractFilter(object):
raise NotImplementedError raise NotImplementedError
class FilterWrapper(object): class FilterWrapper:
name_wrapper_class = None name_wrapper_class = None
def __init__(self, wrapped_filter): def __init__(self, wrapped_filter):
@@ -229,7 +229,7 @@ class DictFilter(AbstractFilter):
return '<%s: for {%s}>' % (self.__class__.__name__, keys) return '<%s: for {%s}>' % (self.__class__.__name__, keys)
class MergedFilter(object): class MergedFilter:
def __init__(self, *filters): def __init__(self, *filters):
self._filters = filters self._filters = filters
@@ -320,7 +320,7 @@ class _OverwriteMeta(type):
cls.overwritten_methods = base_dct cls.overwritten_methods = base_dct
class _AttributeOverwriteMixin(object): class _AttributeOverwriteMixin:
def get_filters(self, *args, **kwargs): def get_filters(self, *args, **kwargs):
yield SpecialMethodFilter(self, self.overwritten_methods, self._wrapped_value) yield SpecialMethodFilter(self, self.overwritten_methods, self._wrapped_value)
yield from self._wrapped_value.get_filters(*args, **kwargs) yield from self._wrapped_value.get_filters(*args, **kwargs)

View File

@@ -3,7 +3,7 @@ from jedi.inference.recursion import execution_allowed
from jedi.inference.helpers import is_big_annoying_library from jedi.inference.helpers import is_big_annoying_library
class Status(object): class Status:
lookup_table = {} lookup_table = {}
def __init__(self, value, name): def __init__(self, value, name):

View File

@@ -37,7 +37,7 @@ class _BoundTypeVarName(AbstractNameDefinition):
return '<%s %s -> %s>' % (self.__class__.__name__, self.py__name__(), self._value_set) 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. A filter for all given variables in a class.
@@ -246,7 +246,7 @@ class GenericClass(DefineGenericBaseClass, ClassMixin):
return type_var_dict return type_var_dict
class _LazyGenericBaseClass(object): class _LazyGenericBaseClass:
def __init__(self, class_value, lazy_base_class, generics_manager): def __init__(self, class_value, lazy_base_class, generics_manager):
self._class_value = class_value self._class_value = class_value
self._lazy_base_class = lazy_base_class self._lazy_base_class = lazy_base_class

View File

@@ -23,7 +23,7 @@ def _resolve_forward_references(context, value_set):
yield value yield value
class _AbstractGenericManager(object): class _AbstractGenericManager:
def get_index_and_execute(self, index): def get_index_and_execute(self, index):
try: try:
return self[index].execute_annotation() return self[index].execute_annotation()

View File

@@ -32,7 +32,7 @@ from jedi.inference.compiled.subprocess.functions import ImplicitNSInfo
from jedi.plugins import plugin_manager from jedi.plugins import plugin_manager
class ModuleCache(object): class ModuleCache:
def __init__(self): def __init__(self):
self._name_cache = {} self._name_cache = {}
@@ -150,7 +150,7 @@ def _level_to_base_import_path(project_path, directory, level):
return None, directory return None, directory
class Importer(object): class Importer:
def __init__(self, inference_state, import_path, module_context, level=0): def __init__(self, inference_state, import_path, module_context, level=0):
""" """
An implementation similar to ``__import__``. Use `follow` An implementation similar to ``__import__``. Use `follow`

View File

@@ -2,7 +2,7 @@ from jedi.inference.base_value import ValueSet, NO_VALUES
from jedi.common import monkeypatch from jedi.common import monkeypatch
class AbstractLazyValue(object): class AbstractLazyValue:
def __init__(self, data, min=1, max=1): def __init__(self, data, min=1, max=1):
self.data = data self.data = data
self.min = min self.min = min

View File

@@ -23,7 +23,7 @@ def _merge_name_docs(names):
return doc return doc
class AbstractNameDefinition(object): class AbstractNameDefinition:
start_pos = None start_pos = None
string_name = None string_name = None
parent_context = None parent_context = None
@@ -223,7 +223,7 @@ class AbstractTreeName(AbstractNameDefinition):
return self.tree_name.start_pos return self.tree_name.start_pos
class ValueNameMixin(object): class ValueNameMixin:
def infer(self): def infer(self):
return ValueSet([self._value]) return ValueSet([self._value])
@@ -346,7 +346,7 @@ class TreeNameDefinition(AbstractTreeName):
return '' return ''
class _ParamMixin(object): class _ParamMixin:
def maybe_positional_argument(self, include_star=True): def maybe_positional_argument(self, include_star=True):
options = [Parameter.POSITIONAL_ONLY, Parameter.POSITIONAL_OR_KEYWORD] options = [Parameter.POSITIONAL_ONLY, Parameter.POSITIONAL_OR_KEYWORD]
if include_star: if include_star:
@@ -604,7 +604,7 @@ class SubModuleName(ImportName):
_level = 1 _level = 1
class NameWrapper(object): class NameWrapper:
def __init__(self, wrapped_name): def __init__(self, wrapped_name):
self._wrapped_name = wrapped_name self._wrapped_name = wrapped_name
@@ -615,7 +615,7 @@ class NameWrapper(object):
return '%s(%s)' % (self.__class__.__name__, self._wrapped_name) return '%s(%s)' % (self.__class__.__name__, self._wrapped_name)
class StubNameMixin(object): class StubNameMixin:
def py__doc__(self): def py__doc__(self):
from jedi.inference.gradual.conversion import convert_names from jedi.inference.gradual.conversion import convert_names
# Stubs are not complicated and we can just follow simple statements # Stubs are not complicated and we can just follow simple statements

View File

@@ -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): def __init__(self):
self.pushed_nodes = [] self.pushed_nodes = []
@@ -92,7 +92,7 @@ def execution_recursion_decorator(default=NO_VALUES):
return decorator return decorator
class ExecutionRecursionDetector(object): class ExecutionRecursionDetector:
""" """
Catches recursions of executions. Catches recursions of executions.
""" """

View File

@@ -5,7 +5,7 @@ from jedi import debug
from jedi import parser_utils from jedi import parser_utils
class _SignatureMixin(object): class _SignatureMixin:
def to_string(self): def to_string(self):
def param_strings(): def param_strings():
is_positional = False is_positional = False

View File

@@ -70,7 +70,7 @@ def reraise_uncaught(func):
return wrapper return wrapper
class PushBackIterator(object): class PushBackIterator:
def __init__(self, iterator): def __init__(self, iterator):
self.pushes = [] self.pushes = []
self.iterator = iterator self.iterator = iterator

View File

@@ -53,7 +53,7 @@ class FunctionAndClassBase(TreeValue):
return None return None
class FunctionMixin(object): class FunctionMixin:
api_type = 'function' api_type = 'function'
def get_filters(self, origin_scope=None): def get_filters(self, origin_scope=None):

View File

@@ -19,7 +19,7 @@ from jedi.inference.context import CompForContext
from jedi.inference.value.dynamic_arrays import check_array_additions from jedi.inference.value.dynamic_arrays import check_array_additions
class IterableMixin(object): class IterableMixin:
def py__next__(self, contextualized_node=None): def py__next__(self, contextualized_node=None):
return self.py__iter__(contextualized_node) 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() @inference_state_method_cache()
def _get_comp_for_context(self, parent_context, comp_for): def _get_comp_for_context(self, parent_context, comp_for):
return CompForContext(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) return "<%s of %s>" % (type(self).__name__, self._sync_comp_for_node)
class _DictMixin(object): class _DictMixin:
def _get_generics(self): def _get_generics(self):
return tuple(c_set.py__class__() for c_set in self.get_mapping_item_values()) return tuple(c_set.py__class__() for c_set in self.get_mapping_item_values())
@@ -247,7 +247,7 @@ class GeneratorComprehension(_BaseComprehension, GeneratorBase):
pass pass
class _DictKeyMixin(object): class _DictKeyMixin:
# TODO merge with _DictMixin? # TODO merge with _DictMixin?
def get_mapping_item_values(self): def get_mapping_item_values(self):
return self._dict_keys(), self._dict_values() return self._dict_keys(), self._dict_values()

View File

@@ -142,7 +142,7 @@ class ClassFilter(ParserTreeFilter):
return [name for name in names if self._access_possible(name)] return [name for name in names if self._access_possible(name)]
class ClassMixin(object): class ClassMixin:
def is_class(self): def is_class(self):
return True return True

View File

@@ -33,7 +33,7 @@ class _ModuleAttributeName(AbstractNameDefinition):
return compiled.get_string_value_set(self.parent_context.inference_state) return compiled.get_string_value_set(self.parent_context.inference_state)
class SubModuleDictMixin(object): class SubModuleDictMixin:
@inference_state_method_cache() @inference_state_method_cache()
def sub_modules_dict(self): def sub_modules_dict(self):
""" """

View File

@@ -1,7 +1,7 @@
from functools import wraps from functools import wraps
class _PluginManager(object): class _PluginManager:
def __init__(self): def __init__(self):
self._registered_plugins = [] self._registered_plugins = []
self._cached_base_callbacks = {} self._cached_base_callbacks = {}

View File

@@ -65,7 +65,7 @@ def setup_readline(namespace_module=__main__, fuzzy=False):
level=logging.DEBUG level=logging.DEBUG
) )
class JediRL(object): class JediRL:
def complete(self, text, state): def complete(self, text, state):
""" """
This complete stuff is pretty weird, a generator would make This complete stuff is pretty weird, a generator would make