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


Python ClassDef.fullname方法代码示例

本文整理汇总了Python中mypy.nodes.ClassDef.fullname方法的典型用法代码示例。如果您正苦于以下问题:Python ClassDef.fullname方法的具体用法?Python ClassDef.fullname怎么用?Python ClassDef.fullname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mypy.nodes.ClassDef的用法示例。


在下文中一共展示了ClassDef.fullname方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: make_type_info

# 需要导入模块: from mypy.nodes import ClassDef [as 别名]
# 或者: from mypy.nodes.ClassDef import fullname [as 别名]
def make_type_info(name: str,
                   is_abstract: bool = False,
                   mro: List[TypeInfo] = None,
                   bases: List[Instance] = None,
                   typevars: List[str] = None) -> TypeInfo:
    """Make a TypeInfo suitable for use in unit tests."""

    class_def = ClassDef(name, Block([]), None, [])
    class_def.fullname = name

    if typevars:
        v = []  # type: List[TypeVarDef]
        id = 1
        for n in typevars:
            v.append(TypeVarDef(n, id, None))
            id += 1
        class_def.type_vars = v

    info = TypeInfo(SymbolTable(), class_def)
    if mro is None:
        mro = []
    info.mro = [info] + mro
    if bases is None:
        if mro:
            # By default, assume that there is a single non-generic base.
            bases = [Instance(mro[0], [])]
        else:
            bases = []
    info.bases = bases

    return info
开发者ID:akaihola,项目名称:mypy,代码行数:33,代码来源:typefixture.py

示例2: stale_info

# 需要导入模块: from mypy.nodes import ClassDef [as 别名]
# 或者: from mypy.nodes.ClassDef import fullname [as 别名]
def stale_info() -> TypeInfo:
    suggestion = "<stale cache: consider running mypy without --quick>"
    dummy_def = ClassDef(suggestion, Block([]))
    dummy_def.fullname = suggestion

    info = TypeInfo(SymbolTable(), dummy_def, "<stale>")
    info.mro = [info]
    info.bases = []
    return info
开发者ID:greatmazinger,项目名称:mypy,代码行数:11,代码来源:fixup.py

示例3: visit_class_def

# 需要导入模块: from mypy.nodes import ClassDef [as 别名]
# 或者: from mypy.nodes.ClassDef import fullname [as 别名]
 def visit_class_def(self, node: ClassDef) -> Node:
     new = ClassDef(node.name, self.block(node.defs), node.type_vars,
                    self.nodes(node.base_type_exprs), node.metaclass)
     new.fullname = node.fullname
     new.info = node.info
     new.decorators = [
         decorator.accept(self) for decorator in node.decorators
     ]
     new.is_builtinclass = node.is_builtinclass
     return new
开发者ID:matthiaskramm,项目名称:mypy,代码行数:12,代码来源:treetransform.py

示例4: stale_info

# 需要导入模块: from mypy.nodes import ClassDef [as 别名]
# 或者: from mypy.nodes.ClassDef import fullname [as 别名]
def stale_info(modules: Dict[str, MypyFile]) -> TypeInfo:
    suggestion = "<stale cache: consider running mypy without --quick>"
    dummy_def = ClassDef(suggestion, Block([]))
    dummy_def.fullname = suggestion

    info = TypeInfo(SymbolTable(), dummy_def, "<stale>")
    obj_type = lookup_qualified(modules, 'builtins.object', False)
    assert isinstance(obj_type, TypeInfo)
    info.bases = [Instance(obj_type, [])]
    info.mro = [info, obj_type]
    return info
开发者ID:sixolet,项目名称:mypy,代码行数:13,代码来源:fixup.py

示例5: visit_class_def

# 需要导入模块: from mypy.nodes import ClassDef [as 别名]
# 或者: from mypy.nodes.ClassDef import fullname [as 别名]
 def visit_class_def(self, node: ClassDef) -> ClassDef:
     new = ClassDef(node.name,
                    self.block(node.defs),
                    node.type_vars,
                    self.expressions(node.base_type_exprs),
                    node.metaclass)
     new.fullname = node.fullname
     new.info = node.info
     new.decorators = [self.expr(decorator)
                       for decorator in node.decorators]
     return new
开发者ID:alexandrul,项目名称:mypy,代码行数:13,代码来源:treetransform.py

示例6: add_info_hook

# 需要导入模块: from mypy.nodes import ClassDef [as 别名]
# 或者: from mypy.nodes.ClassDef import fullname [as 别名]
def add_info_hook(ctx) -> None:
    class_def = ClassDef(ctx.name, Block([]))
    class_def.fullname = ctx.api.qualified_name(ctx.name)

    info = TypeInfo(SymbolTable(), class_def, ctx.api.cur_mod_id)
    class_def.info = info
    obj = ctx.api.builtin_type('builtins.object')
    info.mro = [info, obj.type]
    info.bases = [obj]
    ctx.api.add_symbol_table_node(ctx.name, SymbolTableNode(GDEF, info))
    info.metadata['magic'] = True
开发者ID:Michael0x2a,项目名称:mypy,代码行数:13,代码来源:common_api_incremental.py

示例7: missing_info

# 需要导入模块: from mypy.nodes import ClassDef [as 别名]
# 或者: from mypy.nodes.ClassDef import fullname [as 别名]
def missing_info(modules: Dict[str, MypyFile]) -> TypeInfo:
    suggestion = "<missing info: *should* have gone away during fine-grained update>"
    dummy_def = ClassDef(suggestion, Block([]))
    dummy_def.fullname = suggestion

    info = TypeInfo(SymbolTable(), dummy_def, "<missing>")
    obj_type = lookup_qualified(modules, 'builtins.object', False)
    assert isinstance(obj_type, TypeInfo)
    info.bases = [Instance(obj_type, [])]
    info.mro = [info, obj_type]
    return info
开发者ID:python,项目名称:mypy,代码行数:13,代码来源:fixup.py

示例8: visit_class_def

# 需要导入模块: from mypy.nodes import ClassDef [as 别名]
# 或者: from mypy.nodes.ClassDef import fullname [as 别名]
 def visit_class_def(self, cdef: ClassDef) -> None:
     kind = self.kind_by_scope()
     if kind == LDEF:
         return
     elif kind == GDEF:
         self.sem.check_no_global(cdef.name, cdef)
     cdef.fullname = self.sem.qualified_name(cdef.name)
     info = TypeInfo(SymbolTable(), cdef, self.sem.cur_mod_id)
     info.set_line(cdef.line, cdef.column)
     cdef.info = info
     if kind == GDEF:
         self.sem.globals[cdef.name] = SymbolTableNode(kind, info)
     self.process_nested_classes(cdef)
开发者ID:sixolet,项目名称:mypy,代码行数:15,代码来源:semanal_pass1.py

示例9: make_type_info

# 需要导入模块: from mypy.nodes import ClassDef [as 别名]
# 或者: from mypy.nodes.ClassDef import fullname [as 别名]
    def make_type_info(self, name: str,
                       module_name: Optional[str] = None,
                       is_abstract: bool = False,
                       mro: Optional[List[TypeInfo]] = None,
                       bases: Optional[List[Instance]] = None,
                       typevars: Optional[List[str]] = None,
                       variances: Optional[List[int]] = None) -> TypeInfo:
        """Make a TypeInfo suitable for use in unit tests."""

        class_def = ClassDef(name, Block([]), None, [])
        class_def.fullname = name

        if module_name is None:
            if '.' in name:
                module_name = name.rsplit('.', 1)[0]
            else:
                module_name = '__main__'

        if typevars:
            v = []  # type: List[TypeVarDef]
            for id, n in enumerate(typevars, 1):
                if variances:
                    variance = variances[id - 1]
                else:
                    variance = COVARIANT
                v.append(TypeVarDef(n, n, id, [], self.o, variance=variance))
            class_def.type_vars = v

        info = TypeInfo(SymbolTable(), class_def, module_name)
        if mro is None:
            mro = []
            if name != 'builtins.object':
                mro.append(self.oi)
        info.mro = [info] + mro
        if bases is None:
            if mro:
                # By default, assume that there is a single non-generic base.
                bases = [Instance(mro[0], [])]
            else:
                bases = []
        info.bases = bases

        return info
开发者ID:python,项目名称:mypy,代码行数:45,代码来源:typefixture.py


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