-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[ty] Dataclass transform: complete set of parameters #21474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Diagnostic diff on typing conformance testsNo changes detected when running ty on typing conformance tests ✅ |
|
|
95aa333 to
3e52af4
Compare
AlexWaygood
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
| T = TypeVar("T", bound=type) | ||
|
|
||
| @dataclass_transform() | ||
| def fancy_model(*, slots: bool = False) -> Callable[[T], T]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't slots=False the default default? Wouldn't a more interesting test be this?
| def fancy_model(*, slots: bool = False) -> Callable[[T], T]: | |
| def fancy_model(*, slots: bool = True) -> Callable[[T], T]: |
(The same applies to your other examples below!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default parameter here has no actual effect on anything. slots=False is the default behavior and there is no way to override this for a dataclass-transformer. There is no slots_default parameter for the dataclass_transform call.
For the parameters that can actually change their defaults (like kw_only), we already have tests elsewhere in this file. Here, we just test that we can also modify something like slots on an actual model/dataclass (not on the transformer / the template).
3e52af4 to
528afe2
Compare
* origin/main: (26 commits) Mention `force-exclude` in "Configuration > Python file discovery" (#21500) Avoid syntax error when formatting attribute expressions with outer parentheses, parenthesized value, and trailing comment on value (#20418) [ty] suppress invalid suggestions in import statements (#21484) Limit `eglot-format` hook to eglot-managed Python buffers (#21459) Adjust own-line comment placement between branches (#21185) [ty] Subscript assignment diagnostics follow-up (#21452) [ty] Inlay hint call argument location (#20349) [ty] Use `CompactStr` for `StringLiteralType` (#21497) Update CodSpeedHQ/action action to v4.3.4 (#21488) Update salsa digest to a885bb4 (#21486) Update dependency ruff to v0.14.5 (#21489) Update astral-sh/setup-uv action to v7.1.3 (#21487) Update Rust crate get-size2 to v0.7.2 (#21490) Update Rust crate indicatif to v0.18.3 (#21491) Update Rust crate quick-junit to v0.5.2 (#21492) Update taiki-e/install-action action to v2.62.52 (#21493) Fix analyze graph tests on windows (#21481) `analyze`: Add option to skip over imports in `TYPE_CHECKING` blocks (#21472) [ty] Dataclasses: `__hash__` semantics and `unsafe_hash` (#21470) [ty] Dataclass transform: complete set of parameters (#21474) ...
Summary
We previously only allowed models to overwrite the
{eq,order,kw_only,frozen}_defaultsof the dataclass-transformer, but all other standard-dataclass parameters should be equally supported with the same behavior.Test Plan
Added regression tests.