本文整理汇总了Python中mypy.nodes.ClassDef.decorators方法的典型用法代码示例。如果您正苦于以下问题:Python ClassDef.decorators方法的具体用法?Python ClassDef.decorators怎么用?Python ClassDef.decorators使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mypy.nodes.ClassDef
的用法示例。
在下文中一共展示了ClassDef.decorators方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: visit_class_def
# 需要导入模块: from mypy.nodes import ClassDef [as 别名]
# 或者: from mypy.nodes.ClassDef import decorators [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
示例2: visit_ClassDef
# 需要导入模块: from mypy.nodes import ClassDef [as 别名]
# 或者: from mypy.nodes.ClassDef import decorators [as 别名]
def visit_ClassDef(self, n: ast27.ClassDef) -> ClassDef:
self.class_nesting += 1
cdef = ClassDef(n.name,
self.as_block(n.body, n.lineno),
None,
self.translate_expr_list(n.bases),
metaclass=None)
cdef.decorators = self.translate_expr_list(n.decorator_list)
self.class_nesting -= 1
return cdef
示例3: visit_class_def
# 需要导入模块: from mypy.nodes import ClassDef [as 别名]
# 或者: from mypy.nodes.ClassDef import decorators [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
示例4: visit_ClassDef
# 需要导入模块: from mypy.nodes import ClassDef [as 别名]
# 或者: from mypy.nodes.ClassDef import decorators [as 别名]
def visit_ClassDef(self, n: ast3.ClassDef) -> ClassDef:
self.class_nesting += 1
keywords = [(kw.arg, self.visit(kw.value))
for kw in n.keywords if kw.arg]
cdef = ClassDef(n.name,
self.as_required_block(n.body, n.lineno),
None,
self.translate_expr_list(n.bases),
metaclass=dict(keywords).get('metaclass'),
keywords=keywords)
cdef.decorators = self.translate_expr_list(n.decorator_list)
self.class_nesting -= 1
return cdef
示例5: visit_ClassDef
# 需要导入模块: from mypy.nodes import ClassDef [as 别名]
# 或者: from mypy.nodes.ClassDef import decorators [as 别名]
def visit_ClassDef(self, n: ast27.ClassDef) -> ClassDef:
self.class_and_function_stack.append('C')
cdef = ClassDef(n.name,
self.as_required_block(n.body, n.lineno),
None,
self.translate_expr_list(n.bases),
metaclass=None)
cdef.decorators = self.translate_expr_list(n.decorator_list)
cdef.line = n.lineno + len(n.decorator_list)
cdef.column = n.col_offset
cdef.end_line = n.lineno
self.class_and_function_stack.pop()
return cdef
示例6: visit_ClassDef
# 需要导入模块: from mypy.nodes import ClassDef [as 别名]
# 或者: from mypy.nodes.ClassDef import decorators [as 别名]
def visit_ClassDef(self, n: ast35.ClassDef) -> Node:
self.class_nesting += 1
metaclass_arg = find(lambda x: x.arg == 'metaclass', n.keywords)
metaclass = None
if metaclass_arg:
metaclass = self.stringify_name(metaclass_arg.value)
cdef = ClassDef(n.name,
Block(self.fix_function_overloads(self.visit_list(n.body))),
None,
self.visit_list(n.bases),
metaclass=metaclass)
cdef.decorators = self.visit_list(n.decorator_list)
self.class_nesting -= 1
return cdef
示例7: visit_ClassDef
# 需要导入模块: from mypy.nodes import ClassDef [as 别名]
# 或者: from mypy.nodes.ClassDef import decorators [as 别名]
def visit_ClassDef(self, n):
self.in_class = True
metaclass_arg = find(lambda x: x.arg == 'metaclass', n.keywords)
metaclass = None
if metaclass_arg:
metaclass = self.stringify_name(metaclass_arg.value)
cdef = ClassDef(n.name,
Block(self.fix_function_overloads(self.visit(n.body))),
None,
self.visit(n.bases),
metaclass=metaclass)
cdef.decorators = self.visit(n.decorator_list)
self.in_class = False
return cdef
示例8: visit_ClassDef
# 需要导入模块: from mypy.nodes import ClassDef [as 别名]
# 或者: from mypy.nodes.ClassDef import decorators [as 别名]
def visit_ClassDef(self, n: ast35.ClassDef) -> ClassDef:
self.class_nesting += 1
metaclass_arg = find(lambda x: x.arg == 'metaclass', n.keywords)
metaclass = None
if metaclass_arg:
metaclass = self.stringify_name(metaclass_arg.value)
if metaclass is None:
metaclass = '<error>' # To be reported later
cdef = ClassDef(n.name,
self.as_block(n.body, n.lineno),
None,
self.translate_expr_list(n.bases),
metaclass=metaclass)
cdef.decorators = self.translate_expr_list(n.decorator_list)
self.class_nesting -= 1
return cdef