mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Get rid of is_super_class and do some different things in analysis
This commit is contained in:
@@ -5,7 +5,6 @@ from parso.python import tree
|
||||
|
||||
from jedi._compatibility import force_unicode
|
||||
from jedi import debug
|
||||
from jedi.evaluate.compiled import CompiledObject
|
||||
from jedi.evaluate.helpers import is_string
|
||||
|
||||
|
||||
@@ -145,9 +144,13 @@ def _check_for_exception_catch(node_context, jedi_name, exception, payload=None)
|
||||
Returns True if the exception was catched.
|
||||
"""
|
||||
def check_match(cls, exception):
|
||||
try:
|
||||
return isinstance(cls, CompiledObject) and cls.is_super_class(exception)
|
||||
except TypeError:
|
||||
if not cls.is_class():
|
||||
return False
|
||||
|
||||
for python_cls in exception.mro():
|
||||
if cls.py__name__() == python_cls.__name__ \
|
||||
and cls.parent_context == cls.evaluator.builtins_module:
|
||||
return True
|
||||
return False
|
||||
|
||||
def check_try_for_except(obj, exception):
|
||||
|
||||
@@ -414,9 +414,6 @@ class DirectObjectAccess(object):
|
||||
def negate(self):
|
||||
return self._create_access_path(-self._obj)
|
||||
|
||||
def is_super_class(self, exception):
|
||||
return issubclass(exception, self._obj)
|
||||
|
||||
def get_dir_infos(self):
|
||||
"""
|
||||
Used to return a couple of infos that are needed when accessing the sub
|
||||
|
||||
@@ -223,9 +223,6 @@ class CompiledObject(Context):
|
||||
def negate(self):
|
||||
return create_from_access_path(self.evaluator, self.access_handle.negate())
|
||||
|
||||
def is_super_class(self, exception):
|
||||
return self.access_handle.is_super_class(exception)
|
||||
|
||||
|
||||
class CompiledName(AbstractNameDefinition):
|
||||
def __init__(self, evaluator, parent_context, name):
|
||||
|
||||
@@ -153,8 +153,7 @@ class AbstractInstanceContext(Context):
|
||||
def py__iter__(self, contextualized_node=None):
|
||||
iter_slot_names = self.get_function_slot_names(u'__iter__')
|
||||
if not iter_slot_names:
|
||||
debug.warning('No __iter__ on %s.' % self)
|
||||
return
|
||||
return super(AbstractInstanceContext, self).py__iter__(contextualized_node)
|
||||
|
||||
for generator in self.execute_function_slots(iter_slot_names):
|
||||
if generator.is_instance():
|
||||
|
||||
Reference in New Issue
Block a user