ruff/crates/ty_python_semantic/resources/mdtest/dataclasses
David Peter c8133104e8
[ty] Use field-specifier return type as the default type for the field (#20915)
## Summary

`dataclasses.field` and field-specifier functions of commonly used
libraries like `pydantic`, `attrs`, and `SQLAlchemy` all return the
default type for the field (or `Any`) instead of an actual `Field`
instance, even if this is not what happens at runtime. Let's make use of
this fact and assume that *all* field specifiers return the type of the
default value of the field.

For standard dataclasses, this leads to more or less the same outcome
(see test diff for details), but this change is important for 3rd party
dataclass-transformers.

## Test Plan

Tested the consequences of this change on the field-specifiers branch as
well.
2025-10-16 13:13:45 +02:00
..
dataclass_transform.md [ty] Additional tests for dataclass_transform (class-level overwrites, field_specifiers) (#20788) 2025-10-10 11:22:06 +00:00
dataclasses.md [ty] Do not assume that fields have a default value (#20914) 2025-10-16 12:49:24 +02:00
fields.md [ty] Use field-specifier return type as the default type for the field (#20915) 2025-10-16 13:13:45 +02:00