ruff
bd522584 - [ty] Avoid MRO cycle when collecting NamedTuple fields (#26464)

Commit
1 day ago
[ty] Avoid MRO cycle when collecting NamedTuple fields (#26464) ## Summary When we build the MRO for a class-syntax `NamedTuple`, we synthesize its tuple base from the class's own field types. `own_fields` previously queried `typed_dict_params` unconditionally, even though only `TypedDict` field generation uses those parameters. That query checks whether the class is a `TypedDict` by walking its MRO, re-entering the MRO construction already in progress. This evaluates policy-specific field metadata only for the field kind that consumes it: the `TypedDict` `total` default is read only for `TypedDict` fields, binding defaults are inferred only for `NamedTuple` and dataclass fields, and `KW_ONLY` sentinels are checked only for dataclasses. In particular, gating the `typed_dict_params` lookup removes the `MRO -> own_fields -> MRO` dependency without changing field generation. The recursive generic `NamedTuple` from the issue is covered under Python 3.14. The full ty semantic test suite, package Clippy, and repository hooks pass. Closes https://github.com/astral-sh/ty/issues/3872.
Author
Parents
Loading