mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 06:24: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._compatibility import force_unicode
|
||||||
from jedi import debug
|
from jedi import debug
|
||||||
from jedi.evaluate.compiled import CompiledObject
|
|
||||||
from jedi.evaluate.helpers import is_string
|
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.
|
Returns True if the exception was catched.
|
||||||
"""
|
"""
|
||||||
def check_match(cls, exception):
|
def check_match(cls, exception):
|
||||||
try:
|
if not cls.is_class():
|
||||||
return isinstance(cls, CompiledObject) and cls.is_super_class(exception)
|
return False
|
||||||
except TypeError:
|
|
||||||
|
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
|
return False
|
||||||
|
|
||||||
def check_try_for_except(obj, exception):
|
def check_try_for_except(obj, exception):
|
||||||
|
|||||||
@@ -414,9 +414,6 @@ class DirectObjectAccess(object):
|
|||||||
def negate(self):
|
def negate(self):
|
||||||
return self._create_access_path(-self._obj)
|
return self._create_access_path(-self._obj)
|
||||||
|
|
||||||
def is_super_class(self, exception):
|
|
||||||
return issubclass(exception, self._obj)
|
|
||||||
|
|
||||||
def get_dir_infos(self):
|
def get_dir_infos(self):
|
||||||
"""
|
"""
|
||||||
Used to return a couple of infos that are needed when accessing the sub
|
Used to return a couple of infos that are needed when accessing the sub
|
||||||
|
|||||||
@@ -223,9 +223,6 @@ class CompiledObject(Context):
|
|||||||
def negate(self):
|
def negate(self):
|
||||||
return create_from_access_path(self.evaluator, self.access_handle.negate())
|
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):
|
class CompiledName(AbstractNameDefinition):
|
||||||
def __init__(self, evaluator, parent_context, name):
|
def __init__(self, evaluator, parent_context, name):
|
||||||
|
|||||||
@@ -153,8 +153,7 @@ class AbstractInstanceContext(Context):
|
|||||||
def py__iter__(self, contextualized_node=None):
|
def py__iter__(self, contextualized_node=None):
|
||||||
iter_slot_names = self.get_function_slot_names(u'__iter__')
|
iter_slot_names = self.get_function_slot_names(u'__iter__')
|
||||||
if not iter_slot_names:
|
if not iter_slot_names:
|
||||||
debug.warning('No __iter__ on %s.' % self)
|
return super(AbstractInstanceContext, self).py__iter__(contextualized_node)
|
||||||
return
|
|
||||||
|
|
||||||
for generator in self.execute_function_slots(iter_slot_names):
|
for generator in self.execute_function_slots(iter_slot_names):
|
||||||
if generator.is_instance():
|
if generator.is_instance():
|
||||||
|
|||||||
Reference in New Issue
Block a user