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

Method _combined_context

mypy/checkexpr.py:6074–6086  ·  view source on GitHub ↗
(self, ty: Type | None)

Source from the content-addressed store, hash-verified

6072 return self.accept(node, type_context=context, allow_none_return=allow_none_return)
6073
6074 def _combined_context(self, ty: Type | None) -> Type | None:
6075 ctx_items = []
6076 if ty is not None:
6077 if has_any_type(ty):
6078 # HACK: Any should be contagious, `dict[str, Any] or <x>` should still
6079 # infer Any in x.
6080 return ty
6081 ctx_items.append(ty)
6082 if self.type_context and self.type_context[-1] is not None:
6083 ctx_items.append(self.type_context[-1])
6084 if ctx_items:
6085 return make_simplified_union(ctx_items)
6086 return None
6087
6088 #
6089 # Helpers

Callers 1

check_boolean_opMethod · 0.95

Calls 3

make_simplified_unionFunction · 0.90
has_any_typeFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected