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


Python ClassDef.decorators方法代码示例

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

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

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

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

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

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

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

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


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