本文整理汇总了Python中mypy.types.CallableType.max_fixed_args方法的典型用法代码示例。如果您正苦于以下问题:Python CallableType.max_fixed_args方法的具体用法?Python CallableType.max_fixed_args怎么用?Python CallableType.max_fixed_args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mypy.types.CallableType
的用法示例。
在下文中一共展示了CallableType.max_fixed_args方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: is_var_arg_callable_subtype_helper
# 需要导入模块: from mypy.types import CallableType [as 别名]
# 或者: from mypy.types.CallableType import max_fixed_args [as 别名]
def is_var_arg_callable_subtype_helper(left: CallableType, right: CallableType) -> bool:
"""Is left a subtype of right, assuming left has *args?
See also is_callable_subtype for additional assumptions we can make.
"""
left_fixed = left.max_fixed_args()
right_fixed = right.max_fixed_args()
num_fixed_matching = min(left_fixed, right_fixed)
for i in range(num_fixed_matching):
if not is_subtype(right.arg_types[i], left.arg_types[i]):
return False
if not right.is_var_arg:
for i in range(num_fixed_matching, len(right.arg_types)):
if not is_subtype(right.arg_types[i], left.arg_types[-1]):
return False
return True
else:
for i in range(left_fixed, right_fixed):
if not is_subtype(right.arg_types[i], left.arg_types[-1]):
return False
for i in range(right_fixed, left_fixed):
if not is_subtype(right.arg_types[-1], left.arg_types[i]):
return False
return is_subtype(right.arg_types[-1], left.arg_types[-1])