MCPcopy Index your code
hub / github.com/python/mypy / safe_meet

Function safe_meet

mypy/join.py:795–814  ·  view source on GitHub ↗
(t: Type, s: Type)

Source from the content-addressed store, hash-verified

793
794
795def safe_meet(t: Type, s: Type) -> Type:
796 # Similar to above but for meet_types().
797 from mypy.meet import meet_types
798
799 if not isinstance(t, UnpackType) and not isinstance(s, UnpackType):
800 return meet_types(t, s)
801 if isinstance(t, UnpackType) and isinstance(s, UnpackType):
802 unpacked = get_proper_type(t.type)
803 if isinstance(unpacked, TypeVarTupleType):
804 fallback_type = unpacked.tuple_fallback.type
805 elif isinstance(unpacked, TupleType):
806 fallback_type = unpacked.partial_fallback.type
807 else:
808 assert isinstance(unpacked, Instance) and unpacked.type.fullname == "builtins.tuple"
809 fallback_type = unpacked.type
810 res = meet_types(t.type, s.type)
811 if isinstance(res, UninhabitedType):
812 res = Instance(fallback_type, [res])
813 return UnpackType(res)
814 return UninhabitedType()
815
816
817def combine_similar_callables(t: CallableType, s: CallableType) -> CallableType:

Callers 1

join_similar_callablesFunction · 0.85

Calls 6

meet_typesFunction · 0.90
get_proper_typeFunction · 0.90
InstanceClass · 0.90
UnpackTypeClass · 0.90
UninhabitedTypeClass · 0.90
isinstanceFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…