(
mapping: list[int], actual_types: list[Type], actual_kinds: list[ArgKind]
)
| 6652 | |
| 6653 | |
| 6654 | def is_duplicate_mapping( |
| 6655 | mapping: list[int], actual_types: list[Type], actual_kinds: list[ArgKind] |
| 6656 | ) -> bool: |
| 6657 | return ( |
| 6658 | len(mapping) > 1 |
| 6659 | # Multiple actuals can map to the same formal if they both come from |
| 6660 | # varargs (*args and **kwargs); in this case at runtime it is possible |
| 6661 | # that here are no duplicates. We need to allow this, as the convention |
| 6662 | # f(..., *args, **kwargs) is common enough. |
| 6663 | and not ( |
| 6664 | len(mapping) == 2 |
| 6665 | and actual_kinds[mapping[0]] == nodes.ARG_STAR |
| 6666 | and actual_kinds[mapping[1]] == nodes.ARG_STAR2 |
| 6667 | ) |
| 6668 | # Multiple actuals can map to the same formal if there are multiple |
| 6669 | # **kwargs which cannot be mapped with certainty (non-TypedDict |
| 6670 | # **kwargs). |
| 6671 | and not all( |
| 6672 | actual_kinds[m] == nodes.ARG_STAR2 |
| 6673 | and not isinstance(get_proper_type(actual_types[m]), TypedDictType) |
| 6674 | for m in mapping |
| 6675 | ) |
| 6676 | ) |
| 6677 | |
| 6678 | |
| 6679 | def replace_callable_return_type(c: CallableType, new_ret_type: Type) -> CallableType: |
no test coverage detected
searching dependent graphs…