MCPcopy
hub / github.com/python/mypy / append_union_note

Function append_union_note

mypy/messages.py:3431–3445  ·  view source on GitHub ↗

Point to specific union item(s) that may cause failure in subtype check.

(
    notes: list[str], arg_type: UnionType, expected_type: UnionType, options: Options
)

Source from the content-addressed store, hash-verified

3429
3430
3431def append_union_note(
3432 notes: list[str], arg_type: UnionType, expected_type: UnionType, options: Options
3433) -> list[str]:
3434 """Point to specific union item(s) that may cause failure in subtype check."""
3435 non_matching = []
3436 items = flatten_nested_unions(arg_type.items)
3437 if len(items) < MAX_UNION_ITEMS:
3438 return notes
3439 for item in items:
3440 if not is_subtype(item, expected_type):
3441 non_matching.append(item)
3442 if non_matching:
3443 types = ", ".join([format_type(typ, options) for typ in non_matching])
3444 notes.append(f"Item{plural_s(non_matching)} in the first union not in the second: {types}")
3445 return notes
3446
3447
3448def append_numbers_notes(

Callers 1

check_subtypeMethod · 0.90

Calls 7

flatten_nested_unionsFunction · 0.90
is_subtypeFunction · 0.90
plural_sFunction · 0.90
lenFunction · 0.85
format_typeFunction · 0.85
appendMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…