Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This fixes a test failure in which pytype was unable to find the expected wrong-arg-types error in the following snippet in 3.9: from typing import Dict def f(x, **kwargs: int): return kwargs def g() -> Dict[str, float]: return __any_object__ f("", **g()) # wrong-arg-types Before 3.9, when the return value of a function becomes the **kwargs input to another function, that return value is used directly. For pytype, this means that the ParameterizedClass(dict, {_K: str, _V: float}) object constructed as the return type of g gets successfully passed into f. Starting in 3.9, the return value is instead passed to the DICT_MERGE opcode and merged into an empty dict, so the pytype object passed into f ends up being an instance of a plain dict, with the instance parameters set to Instance(str) and Instance(float). When this case is detected, we now reconstruct a parameterized dict class to match the pre-3.9 behavior. PiperOrigin-RevId: 398787107
- Loading branch information