本文整理汇总了Python中mypy.nodes.ClassDef.removed_base_type_exprs方法的典型用法代码示例。如果您正苦于以下问题:Python ClassDef.removed_base_type_exprs方法的具体用法?Python ClassDef.removed_base_type_exprs怎么用?Python ClassDef.removed_base_type_exprs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mypy.nodes.ClassDef
的用法示例。
在下文中一共展示了ClassDef.removed_base_type_exprs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: visit_class_def
# 需要导入模块: from mypy.nodes import ClassDef [as 别名]
# 或者: from mypy.nodes.ClassDef import removed_base_type_exprs [as 别名]
def visit_class_def(self, node: ClassDef) -> None:
"""Strip class body and type info, but don't strip methods."""
to_delete = set(self.strip_type_info(node.info))
node.type_vars = []
node.base_type_exprs.extend(node.removed_base_type_exprs)
node.removed_base_type_exprs = []
node.defs.body = [s for s in node.defs.body
if s not in to_delete]
with self.enter_class(node.info):
super().visit_class_def(node)
示例2: visit_class_def
# 需要导入模块: from mypy.nodes import ClassDef [as 别名]
# 或者: from mypy.nodes.ClassDef import removed_base_type_exprs [as 别名]
def visit_class_def(self, node: ClassDef) -> None:
"""Strip class body and type info, but don't strip methods."""
node.info.type_vars = []
node.info.bases = []
node.info.abstract_attributes = []
node.info.mro = []
node.info.add_type_vars()
node.base_type_exprs.extend(node.removed_base_type_exprs)
node.removed_base_type_exprs = []
with self.enter_class(node.info):
super().visit_class_def(node)
示例3: visit_class_def
# 需要导入模块: from mypy.nodes import ClassDef [as 别名]
# 或者: from mypy.nodes.ClassDef import removed_base_type_exprs [as 别名]
def visit_class_def(self, node: ClassDef) -> None:
"""Strip class body and type info, but don't strip methods."""
# We need to save the implicitly defined instance variables,
# i.e. those defined as attributes on self. Otherwise, they would
# be lost if we only reprocess top-levels (this kills TypeInfos)
# but not the methods that defined those variables.
if not self.recurse_into_functions:
self.prepare_implicit_var_patches(node)
# We need to delete any entries that were generated by plugins,
# since they will get regenerated.
to_delete = {v.node for v in node.info.names.values() if v.plugin_generated}
node.type_vars = []
node.base_type_exprs.extend(node.removed_base_type_exprs)
node.removed_base_type_exprs = []
node.defs.body = [s for s in node.defs.body
if s not in to_delete]
with self.enter_class(node.info):
super().visit_class_def(node)
TypeState.reset_subtype_caches_for(node.info)
# Kill the TypeInfo, since there is none before semantic analysis.
node.info = CLASSDEF_NO_INFO