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


Python MessageBuilder.does_not_return_value方法代码示例

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


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

示例1: TypeChecker

# 需要导入模块: from mypy.messages import MessageBuilder [as 别名]
# 或者: from mypy.messages.MessageBuilder import does_not_return_value [as 别名]

#.........这里部分代码省略.........
        return self.expr_checker.visit_list_comprehension(e)

    def visit_generator_expr(self, e):
        return self.expr_checker.visit_generator_expr(e)

    def visit_temp_node(self, e):
        return e.type

    #
    # Currently unsupported features
    #

    def visit_set_expr(self, e):
        return self.msg.not_implemented('set literal', e)

    def visit_conditional_expr(self, e):
        return self.msg.not_implemented('conditional expression', e)

    def visit_decorator(self, e):
        return self.msg.not_implemented('decorator', e)
    
    def visit_with_stmt(self, s):
        self.msg.not_implemented('with statement', s)
    
    #
    # Helpers
    #
    
    def check_subtype(self, subtype, supertype, context, msg=messages.INCOMPATIBLE_TYPES):
        """Generate an error if the subtype is not compatible with
        supertype."""
        if not is_subtype(subtype, supertype):
            if isinstance(subtype, Void):
                self.msg.does_not_return_value(subtype, context)
            else:
                self.fail(msg, context)
    
    def named_type(self, name):
        """Return an instance type with type given by the name and no
        type arguments. For example, named_type('builtins.object')
        produces the object type.
        """
        # Assume that the name refers to a type.
        sym = self.lookup_qualified(name)
        return Instance(sym.node, [])
    
    def named_type_if_exists(self, name):
        """Return named instance type, or UnboundType if the type was
        not defined.
        
        This is used to simplify test cases by avoiding the need to
        define basic types not needed in specific test cases (tuple
        etc.).
        """
        try:
            # Assume that the name refers to a type.
            sym = self.lookup_qualified(name)
            return Instance(sym.node, [])
        except KeyError:
            return UnboundType(name)
    
    def named_generic_type(self, name, args):
        """Return an instance with the given name and type
        arguments. Assume that the number of arguments is correct.
        """
        # Assume that the name refers to a compatible generic type.
开发者ID:SRiikonen,项目名称:mypy-py,代码行数:70,代码来源:checker.py


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