本文整理汇总了Python中mypy.types.CallableType.is_generic方法的典型用法代码示例。如果您正苦于以下问题:Python CallableType.is_generic方法的具体用法?Python CallableType.is_generic怎么用?Python CallableType.is_generic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mypy.types.CallableType
的用法示例。
在下文中一共展示了CallableType.is_generic方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: visit_callable_type
# 需要导入模块: from mypy.types import CallableType [as 别名]
# 或者: from mypy.types.CallableType import is_generic [as 别名]
def visit_callable_type(self, t: CallableType) -> Type:
if isinstance(self.s, CallableType) and is_similar_callables(t, self.s):
if is_equivalent(t, self.s):
return combine_similar_callables(t, self.s)
result = meet_similar_callables(t, self.s)
if isinstance(result.ret_type, UninhabitedType):
# Return a plain None or <uninhabited> instead of a weird function.
return self.default(self.s)
return result
elif isinstance(self.s, TypeType) and t.is_type_obj() and not t.is_generic():
# In this case we are able to potentially produce a better meet.
res = meet_types(self.s.item, t.ret_type)
if not isinstance(res, (NoneType, UninhabitedType)):
return TypeType.make_normalized(res)
return self.default(self.s)
elif isinstance(self.s, Instance) and self.s.type.is_protocol:
call = unpack_callback_protocol(self.s)
if call:
return meet_types(t, call)
return self.default(self.s)