當前位置: 首頁>>代碼示例>>Python>>正文


Python ContextSet.from_iterable方法代碼示例

本文整理匯總了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)
開發者ID:BarnetteME1,項目名稱:DnD-stuff,代碼行數:36,代碼來源:stdlib.py

示例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')
開發者ID:andrewgu12,項目名稱:config,代碼行數:11,代碼來源:iterable.py

示例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))
開發者ID:Marslo,項目名稱:VimConfig,代碼行數:15,代碼來源:context.py

示例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)
     )
開發者ID:BarnetteME1,項目名稱:DnD-stuff,代碼行數:8,代碼來源:docstrings.py

示例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()
     )
開發者ID:Marslo,項目名稱:VimConfig,代碼行數:7,代碼來源:context.py


注:本文中的jedi.evaluate.base_context.ContextSet.from_iterable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。