forked from VimPlug/jedi
New "with ignored(*exceptions)" context manager
This commit is contained in:
@@ -9,6 +9,8 @@ instantiated. This class represents these cases.
|
||||
So, why is there also a ``Class`` class here? Well, there are decorators and
|
||||
they change classes in Python 3.
|
||||
"""
|
||||
from __future__ import with_statement
|
||||
|
||||
import copy
|
||||
import itertools
|
||||
|
||||
@@ -61,10 +63,8 @@ class Instance(use_metaclass(cache.CachedMetaClass, Executable)):
|
||||
else:
|
||||
# need to execute the __init__ function, because the dynamic param
|
||||
# searching needs it.
|
||||
try:
|
||||
with common.ignored(KeyError):
|
||||
self.execute_subscope_by_name('__init__', self.var_args)
|
||||
except KeyError:
|
||||
pass
|
||||
# Generated instances are classes that are just generated by self
|
||||
# (No var_args) used.
|
||||
self.is_generated = False
|
||||
@@ -804,10 +804,8 @@ class Array(use_metaclass(cache.CachedMetaClass, pr.Base)):
|
||||
if isinstance(index, Instance) \
|
||||
and str(index.name) in ['int', 'str'] \
|
||||
and len(index.var_args) == 1:
|
||||
try:
|
||||
with common.ignored(KeyError, IndexError):
|
||||
return self.get_exact_index_types(index.var_args[0])
|
||||
except (KeyError, IndexError):
|
||||
pass
|
||||
|
||||
result = list(self._follow_values(self._array.values))
|
||||
result += dynamic.check_array_additions(self)
|
||||
|
||||
Reference in New Issue
Block a user