[ty] Support options in functional dataclass calls#25989
Merged
charliermarsh merged 2 commits intoJun 15, 2026
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 94.36%. The percentage of expected errors that received a diagnostic held steady at 88.91%. The number of fully passing files held steady at 93/134. |
Memory usage reportMemory usage unchanged ✅ |
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
no-matching-overload |
0 | 2 | 0 |
| Total | 0 | 2 | 0 |
Flaky changes detected. This PR summary excludes flaky changes; see the HTML report for details.
Raw diff:
pydantic (https://github.com/pydantic/pydantic)
- pydantic/dataclasses.py:201:19 error[no-matching-overload] No overload of function `dataclass` matches arguments
- pydantic/v1/dataclasses.py:214:26 error[no-matching-overload] No overload of function `dataclass` matches argumentsfc5f2ce to
baed917
Compare
3cd00b0 to
3547eb5
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
880de4d to
b28c34a
Compare
AlexWaygood
approved these changes
Jun 15, 2026
| Parameter::positional_only(Some(Name::new_static("cls"))) | ||
| .with_annotated_type(cls_ty), | ||
| ); | ||
| parameters.extend(decorator_factory_parameters.iter().cloned()); |
Member
There was a problem hiding this comment.
Suggested change
| parameters.extend(decorator_factory_parameters.iter().cloned()); | |
| parameters.extend_from_slice(&decorator_factory_parameters); |
Comment on lines
+2203
to
+2205
| .map_or((None, parameter_types), |(index, _)| { | ||
| (parameter_types[index], ¶meter_types[index + 1..]) | ||
| }); |
Member
There was a problem hiding this comment.
same comment as #25985 (comment), I'd find this much more readable:
Suggested change
| .map_or((None, parameter_types), |(index, _)| { | |
| (parameter_types[index], ¶meter_types[index + 1..]) | |
| }); | |
| .map(|(index, _)| { | |
| (parameter_types[index], ¶meter_types[index + 1..]) | |
| }) | |
| .unwrap_or((None, parameter_types)); |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
dataclassaccepts the same keyword options when it is called directly with a class as when it is used as a decorator factory:Previously, our synthetic overloads only accepted these options when
clswas omitted. Valid calls such asdataclass(Example, frozen=True)therefore producedno-matching-overload, and direct applications always used the default dataclass parameters.This adds the keyword-only options to the direct-call overloads and reads dataclass arguments by parameter name, allowing the computed parameters to be applied consistently to decorator factories, explicit
Nonecalls, and direct class arguments.