[ty] Implement DataClassInstance protocol for dataclasses. by abhijeetbodas2001 · Pull Request #18018 · astral-sh/ruff (original) (raw)

abhijeetbodas2001

@dylwil3 dylwil3 added the ty

Multi-file analysis & type inference

label

May 11, 2025

AlexWaygood

dcreager added a commit that referenced this pull request

May 13, 2025

@dcreager

…eep-dish

Glyphack pushed a commit to Glyphack/ruff that referenced this pull request

May 21, 2025

…sh#18018)

Fixes: astral-sh/ty#92

Summary

We currently get a invalid-argument-type error when using dataclass.fields on a dataclass, because we do not synthesize the __dataclass_fields__ member.

This PR fixes this diagnostic.

Note that we do not yet model the Field type correctly. After that is done, we can assign a more precise tuple[Field, ...] type to this new member.

Test Plan

New mdtest.


Co-authored-by: David Peter mail@david-peter.de

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 }})