本文整理汇总了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.