[ty] Correct return type for synthesized NamedTuple.new methods by bxff · Pull Request #22625 · astral-sh/ruff (original) (raw)
- Uses a synthetic
Selftype variable for__new__in NamedTuple synthesis. - Types the
clsparameter astype[Self]and sets the return type toSelf. - This ensures that
super().__new__calls in subclasses correctly resolve to the subclass type, fixing astral-sh/ty#2522. - Updated named_tuple.md assertions to match the new generic display and added a dedicated regression test case.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})