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

Function is_duplicate_mapping

mypy/checkexpr.py:6654–6676  ·  view source on GitHub ↗
(
    mapping: list[int], actual_types: list[Type], actual_kinds: list[ArgKind]
)

Source from the content-addressed store, hash-verified

6652
6653
6654def 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
6679def replace_callable_return_type(c: CallableType, new_ret_type: Type) -> CallableType:

Callers 1

check_argument_countMethod · 0.85

Calls 4

get_proper_typeFunction · 0.90
lenFunction · 0.85
allFunction · 0.85
isinstanceFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…