Get rid of is_super_class and do some different things in analysis

This commit is contained in:
Dave Halter
2018-11-24 14:09:14 +01:00
parent 021d1bc568
commit 644e292fa7
4 changed files with 8 additions and 12 deletions

View File

@@ -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,11 +144,15 @@ 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):
# Only nodes in try
iterator = iter(obj.children)

View File

@@ -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

View File

@@ -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):

View File

@@ -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():