mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-22 21:31:26 +08:00
Remove py__class__ evaluator param from representation objects.
This commit is contained in:
@@ -60,8 +60,8 @@ class CompiledObject(Base):
|
|||||||
return actual
|
return actual
|
||||||
|
|
||||||
@CheckAttribute
|
@CheckAttribute
|
||||||
def py__class__(self, evaluator):
|
def py__class__(self):
|
||||||
return create(evaluator, self.obj.__class__, parent=self.parent)
|
return create(self._evaluator, self.obj.__class__, parent=self.parent)
|
||||||
|
|
||||||
@CheckAttribute
|
@CheckAttribute
|
||||||
def py__mro__(self):
|
def py__mro__(self):
|
||||||
|
|||||||
@@ -54,9 +54,9 @@ class GeneratorMixin(object):
|
|||||||
def py__bool__(self):
|
def py__bool__(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def py__class__(self, evaluator):
|
def py__class__(self):
|
||||||
gen_obj = compiled.get_special_object(self._evaluator, 'GENERATOR_OBJECT')
|
gen_obj = compiled.get_special_object(self._evaluator, 'GENERATOR_OBJECT')
|
||||||
return gen_obj.py__class__(evaluator)
|
return gen_obj.py__class__()
|
||||||
|
|
||||||
|
|
||||||
class Generator(use_metaclass(CachedMetaClass, IterableWrapper, GeneratorMixin)):
|
class Generator(use_metaclass(CachedMetaClass, IterableWrapper, GeneratorMixin)):
|
||||||
@@ -171,8 +171,8 @@ class ArrayMixin(object):
|
|||||||
def py__bool__(self):
|
def py__bool__(self):
|
||||||
return None # We don't know the length, because of appends.
|
return None # We don't know the length, because of appends.
|
||||||
|
|
||||||
def py__class__(self, evaluator):
|
def py__class__(self):
|
||||||
return compiled.builtin_from_name(evaluator, self.type)
|
return compiled.builtin_from_name(self._evaluator, self.type)
|
||||||
|
|
||||||
|
|
||||||
class ListComprehension(Comprehension, ArrayMixin):
|
class ListComprehension(Comprehension, ArrayMixin):
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ py__bool__() Returns True/False/None; None means that
|
|||||||
py__bases__() Returns a list of base classes.
|
py__bases__() Returns a list of base classes.
|
||||||
py__mro__() Returns a list of classes (the mro).
|
py__mro__() Returns a list of classes (the mro).
|
||||||
py__iter__() Returns a generator of a set of types.
|
py__iter__() Returns a generator of a set of types.
|
||||||
|
py__class__() Returns the class of an instance.
|
||||||
py__getitem__(index: int/str) Returns a a set of types of the index.
|
py__getitem__(index: int/str) Returns a a set of types of the index.
|
||||||
Can raise an IndexError/KeyError.
|
Can raise an IndexError/KeyError.
|
||||||
====================================== ========================================
|
====================================== ========================================
|
||||||
@@ -110,7 +111,7 @@ class Instance(use_metaclass(CachedMetaClass, Executed)):
|
|||||||
|
|
||||||
return actual
|
return actual
|
||||||
|
|
||||||
def py__class__(self, evaluator):
|
def py__class__(self):
|
||||||
return self.base
|
return self.base
|
||||||
|
|
||||||
def py__bool__(self):
|
def py__bool__(self):
|
||||||
@@ -458,8 +459,8 @@ class Class(use_metaclass(CachedMetaClass, Wrapper)):
|
|||||||
def py__call__(self, params):
|
def py__call__(self, params):
|
||||||
return set([Instance(self._evaluator, self, params)])
|
return set([Instance(self._evaluator, self, params)])
|
||||||
|
|
||||||
def py__class__(self, evaluator):
|
def py__class__(self):
|
||||||
return compiled.create(evaluator, type)
|
return compiled.create(self._evaluator, type)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def params(self):
|
def params(self):
|
||||||
@@ -576,8 +577,8 @@ class Function(use_metaclass(CachedMetaClass, Wrapper)):
|
|||||||
else:
|
else:
|
||||||
return FunctionExecution(self._evaluator, self, params).get_return_types()
|
return FunctionExecution(self._evaluator, self, params).get_return_types()
|
||||||
|
|
||||||
def py__class__(self, evaluator):
|
def py__class__(self):
|
||||||
return compiled.get_special_object(evaluator, 'FUNCTION_CLASS')
|
return compiled.get_special_object(self._evaluator, 'FUNCTION_CLASS')
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
return getattr(self.base_func, name)
|
return getattr(self.base_func, name)
|
||||||
@@ -916,8 +917,8 @@ class ModuleWrapper(use_metaclass(CachedMetaClass, tree.Module, Wrapper)):
|
|||||||
|
|
||||||
return names
|
return names
|
||||||
|
|
||||||
def py__class__(self, evaluator):
|
def py__class__(self):
|
||||||
return compiled.get_special_object(evaluator, 'MODULE_CLASS')
|
return compiled.get_special_object(self._evaluator, 'MODULE_CLASS')
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
return getattr(self._module, name)
|
return getattr(self._module, name)
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ def builtins_type(evaluator, objects, bases, dicts):
|
|||||||
# It's a type creation... maybe someday...
|
# It's a type creation... maybe someday...
|
||||||
return set()
|
return set()
|
||||||
else:
|
else:
|
||||||
return set([o.py__class__(evaluator) for o in objects])
|
return set([o.py__class__() for o in objects])
|
||||||
|
|
||||||
|
|
||||||
class SuperInstance(er.Instance):
|
class SuperInstance(er.Instance):
|
||||||
@@ -178,7 +178,7 @@ def builtins_isinstance(evaluator, objects, types, arguments):
|
|||||||
bool_results = set([])
|
bool_results = set([])
|
||||||
for o in objects:
|
for o in objects:
|
||||||
try:
|
try:
|
||||||
mro_func = o.py__class__(evaluator).py__mro__
|
mro_func = o.py__class__().py__mro__
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
# This is temporary. Everything should have a class attribute in
|
# This is temporary. Everything should have a class attribute in
|
||||||
# Python?! Maybe we'll leave it here, because some numpy objects or
|
# Python?! Maybe we'll leave it here, because some numpy objects or
|
||||||
|
|||||||
Reference in New Issue
Block a user