本文整理汇总了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
示例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
示例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
示例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
示例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
示例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
示例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
示例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)
示例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