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

Method check_union_call_expr

mypy/checkexpr.py:1501–1527  ·  view source on GitHub ↗

Type check calling a member expression where the base type is a union.

(self, e: CallExpr, object_type: UnionType, member: str)

Source from the content-addressed store, hash-verified

1499 return ret_type
1500
1501 def check_union_call_expr(self, e: CallExpr, object_type: UnionType, member: str) -> Type:
1502 """Type check calling a member expression where the base type is a union."""
1503 res: list[Type] = []
1504 for typ in flatten_nested_unions(object_type.relevant_items()):
1505 # Member access errors are already reported when visiting the member expression.
1506 with self.msg.filter_errors():
1507 item = analyze_member_access(
1508 member,
1509 typ,
1510 e,
1511 is_lvalue=False,
1512 is_super=False,
1513 is_operator=False,
1514 original_type=object_type,
1515 chk=self.chk,
1516 in_literal_context=self.is_literal_context(),
1517 self_type=typ,
1518 )
1519 narrowed = self.narrow_type_from_binder(e.callee, item, skip_non_overlapping=True)
1520 if narrowed is None:
1521 continue
1522 callable_name = self.method_fullname(typ, member)
1523 item_object_type = typ if callable_name else None
1524 res.append(
1525 self.check_call_expr_with_callee_type(narrowed, e, callable_name, item_object_type)
1526 )
1527 return make_simplified_union(res)
1528
1529 def check_call(
1530 self,

Callers 1

Calls 10

is_literal_contextMethod · 0.95
method_fullnameMethod · 0.95
flatten_nested_unionsFunction · 0.90
analyze_member_accessFunction · 0.90
make_simplified_unionFunction · 0.90
relevant_itemsMethod · 0.80
filter_errorsMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected