Point to specific union item(s) that may cause failure in subtype check.
(
notes: list[str], arg_type: UnionType, expected_type: UnionType, options: Options
)
| 3429 | |
| 3430 | |
| 3431 | def 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 | |
| 3448 | def append_numbers_notes( |
no test coverage detected
searching dependent graphs…