当前位置: 首页>>代码示例>>Python>>正文


Python ClassDef.removed_base_type_exprs方法代码示例

本文整理汇总了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)
开发者ID:Michael0x2a,项目名称:mypy,代码行数:13,代码来源:aststrip.py

示例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)
开发者ID:greatmazinger,项目名称:mypy,代码行数:13,代码来源:aststrip.py

示例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
开发者ID:elazarg,项目名称:mypy,代码行数:23,代码来源:aststripnew.py


注:本文中的mypy.nodes.ClassDef.removed_base_type_exprs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。