本文整理汇总了Python中astroid.scoped_nodes.Module方法的典型用法代码示例。如果您正苦于以下问题:Python scoped_nodes.Module方法的具体用法?Python scoped_nodes.Module怎么用?Python scoped_nodes.Module使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类astroid.scoped_nodes
的用法示例。
在下文中一共展示了scoped_nodes.Module方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _object_type
# 需要导入模块: from astroid import scoped_nodes [as 别名]
# 或者: from astroid.scoped_nodes import Module [as 别名]
def _object_type(node, context=None):
astroid_manager = manager.AstroidManager()
builtins = astroid_manager.astroid_cache[BUILTINS]
context = context or contextmod.InferenceContext()
for inferred in node.infer(context=context):
if isinstance(inferred, scoped_nodes.ClassDef):
if inferred.newstyle:
metaclass = inferred.metaclass()
if metaclass:
yield metaclass
continue
yield builtins.getattr('type')[0]
elif isinstance(inferred, (scoped_nodes.Lambda, bases.UnboundMethod)):
yield _function_type(inferred, builtins)
elif isinstance(inferred, scoped_nodes.Module):
yield _build_proxy_class('module', builtins)
else:
yield inferred._proxied
示例2: _object_type
# 需要导入模块: from astroid import scoped_nodes [as 别名]
# 或者: from astroid.scoped_nodes import Module [as 别名]
def _object_type(node, context=None):
astroid_manager = manager.AstroidManager()
builtins = astroid_manager.builtins_module
context = context or contextmod.InferenceContext()
for inferred in node.infer(context=context):
if isinstance(inferred, scoped_nodes.ClassDef):
if inferred.newstyle:
metaclass = inferred.metaclass()
if metaclass:
yield metaclass
continue
yield builtins.getattr("type")[0]
elif isinstance(inferred, (scoped_nodes.Lambda, bases.UnboundMethod)):
yield _function_type(inferred, builtins)
elif isinstance(inferred, scoped_nodes.Module):
yield _build_proxy_class("module", builtins)
else:
yield inferred._proxied
示例3: _object_type
# 需要导入模块: from astroid import scoped_nodes [as 别名]
# 或者: from astroid.scoped_nodes import Module [as 别名]
def _object_type(node, context=None):
astroid_manager = manager.AstroidManager()
builtins = astroid_manager.astroid_cache[BUILTINS]
context = context or contextmod.InferenceContext()
for inferred in node.infer(context=context):
if isinstance(inferred, scoped_nodes.ClassDef):
if inferred.newstyle:
metaclass = inferred.metaclass()
if metaclass:
yield metaclass
continue
yield builtins.getattr("type")[0]
elif isinstance(inferred, (scoped_nodes.Lambda, bases.UnboundMethod)):
yield _function_type(inferred, builtins)
elif isinstance(inferred, scoped_nodes.Module):
yield _build_proxy_class("module", builtins)
else:
yield inferred._proxied
示例4: leave_module
# 需要导入模块: from astroid import scoped_nodes [as 别名]
# 或者: from astroid.scoped_nodes import Module [as 别名]
def leave_module(self, node):
# type: (scoped_nodes.Module) -> None
"""
We perform the actual check just before we leave the module since that's when the file has
been fully processed.
"""
node_file_path = self._get_file_path_for_node(node=node)
third_party_nodes = list(
self._third_party_import_nodes.get(node_file_path, [])
) # type: List[node_classes.Import]
scalyr_init_node = self._scalyr_init_nodes.get(node_file_path, None)
for import_node in third_party_nodes:
self._verify_import_node_comes_after_scalyr_init(
scalyr_init_node=scalyr_init_node, import_node=import_node
)
示例5: visit_module
# 需要导入模块: from astroid import scoped_nodes [as 别名]
# 或者: from astroid.scoped_nodes import Module [as 别名]
def visit_module(self, node):
# type: (scoped_nodes.Module) -> None
self.__current_module = node.name
示例6: leave_module
# 需要导入模块: from astroid import scoped_nodes [as 别名]
# 或者: from astroid.scoped_nodes import Module [as 别名]
def leave_module(self, _node):
# type: (scoped_nodes.Module) -> None
self.__current_module = None