[ty] Implement DataClassInstance protocol for dataclasses. by abhijeetbodas2001 · Pull Request #18018 · astral-sh/ruff (original) (raw)
Multi-file analysis & type inference
label
dcreager added a commit that referenced this pull request
…eep-dish
- origin/main:
[ty] file is always a string inside a Python module (#18071)
[ty] Recognize submodules in self-referential imports (#18005)
[ty] Add a note to the diagnostic if a new builtin is used on an old Python version (#18068)
[ty] Add tests for
elsebranches ofhasattr()narrowing (#18067) [ty] Improve diagnostics forassert_typeandassert_never(#18050) [ty] contribution guide (#18061) [ty] ImplementDataClassInstanceprotocol for dataclasses. (#18018) [ruff_python_ast] Fix redundant visitation of test expressions in elif clause statements (#18064)
Glyphack pushed a commit to Glyphack/ruff that referenced this pull request
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 }})