本文整理汇总了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()
)