本文整理匯總了Python中jedi.evaluate.base_context.ContextSet.from_iterable方法的典型用法代碼示例。如果您正苦於以下問題:Python ContextSet.from_iterable方法的具體用法?Python ContextSet.from_iterable怎麽用?Python ContextSet.from_iterable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類jedi.evaluate.base_context.ContextSet
的用法示例。
在下文中一共展示了ContextSet.from_iterable方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: builtins_isinstance
# 需要導入模塊: from jedi.evaluate.base_context import ContextSet [as 別名]
# 或者: from jedi.evaluate.base_context.ContextSet import from_iterable [as 別名]
def builtins_isinstance(evaluator, objects, types, arguments):
bool_results = set()
for o in objects:
try:
mro_func = o.py__class__().py__mro__
except AttributeError:
# This is temporary. Everything should have a class attribute in
# Python?! Maybe we'll leave it here, because some numpy objects or
# whatever might not.
return ContextSet(compiled.create(True), compiled.create(False))
mro = mro_func()
for cls_or_tup in types:
if cls_or_tup.is_class():
bool_results.add(cls_or_tup in mro)
elif cls_or_tup.name.string_name == 'tuple' \
and cls_or_tup.get_root_context() == evaluator.BUILTINS:
# Check for tuples.
classes = ContextSet.from_sets(
lazy_context.infer()
for lazy_context in cls_or_tup.iterate()
)
bool_results.add(any(cls in mro for cls in classes))
else:
_, lazy_context = list(arguments.unpack())[1]
if isinstance(lazy_context, LazyTreeContext):
node = lazy_context.data
message = 'TypeError: isinstance() arg 2 must be a ' \
'class, type, or tuple of classes and types, ' \
'not %s.' % cls_or_tup
analysis.add(lazy_context._context, 'type-error-isinstance', node, message)
return ContextSet.from_iterable(compiled.create(evaluator, x) for x in bool_results)
示例2: _imitate_items
# 需要導入模塊: from jedi.evaluate.base_context import ContextSet [as 別名]
# 或者: from jedi.evaluate.base_context.ContextSet import from_iterable [as 別名]
def _imitate_items(self):
items = ContextSet.from_iterable(
FakeSequence(
self.evaluator, u'tuple'
(LazyKnownContexts(keys), LazyKnownContexts(values))
) for keys, values in self._iterate()
)
return create_evaluated_sequence_set(self.evaluator, items, sequence_type=u'list')
示例3: py__call__
# 需要導入模塊: from jedi.evaluate.base_context import ContextSet [as 別名]
# 或者: from jedi.evaluate.base_context.ContextSet import from_iterable [as 別名]
def py__call__(self, params):
if self.tree_node is not None and self.tree_node.type == 'funcdef':
from jedi.evaluate.context.function import FunctionContext
return FunctionContext(
self.evaluator,
parent_context=self.parent_context,
funcdef=self.tree_node
).py__call__(params)
if self.access_handle.is_class():
from jedi.evaluate.context import CompiledInstance
return ContextSet(CompiledInstance(self.evaluator, self.parent_context, self, params))
else:
return ContextSet.from_iterable(self._execute_function(params))
示例4: eval_docstring
# 需要導入模塊: from jedi.evaluate.base_context import ContextSet [as 別名]
# 或者: from jedi.evaluate.base_context.ContextSet import from_iterable [as 別名]
def eval_docstring(docstring):
return ContextSet.from_iterable(
p
for param_str in _search_param_in_docstr(docstring, param.name.value)
for p in _evaluate_for_statement_string(module_context, param_str)
)
示例5: dict_values
# 需要導入模塊: from jedi.evaluate.base_context import ContextSet [as 別名]
# 或者: from jedi.evaluate.base_context.ContextSet import from_iterable [as 別名]
def dict_values(self):
return ContextSet.from_iterable(
create_from_access_path(self.evaluator, access)
for access in self.access_handle.dict_values()
)