Skip to content

Conversation

sharkdp
Copy link
Contributor

@sharkdp sharkdp commented Oct 9, 2025

Summary

Respect parameters such as frozen_default for metaclass-based @dataclass_transformer models.

Related to: astral-sh/ty#1260

Typing conformance changes

Those are all correct (new true positives)

Test Plan

New Markdown tests

@sharkdp sharkdp added the ty Multi-file analysis & type inference label Oct 9, 2025

let has_dataclass_param = |param| {
dataclass_params.is_some_and(|params| params.contains(param))
|| transformer_params.is_some_and(|params| params.contains(param))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the key part: we also fall back to the dataclass_transform parameters, if necessary.

Copy link
Contributor

github-actions bot commented Oct 9, 2025

Diagnostic diff on typing conformance tests

Changes were detected when running ty on typing conformance tests
--- old-output.txt	2025-10-09 13:21:29.281810829 +0000
+++ new-output.txt	2025-10-09 13:21:32.604839205 +0000
@@ -292,8 +292,12 @@
 dataclasses_transform_func.py:77:36: error[invalid-return-type] Function always implicitly returns `None`, which is not assignable to return type `T@create_model_frozen`
 dataclasses_transform_func.py:97:1: error[invalid-assignment] Property `id` defined in `Customer3` is read-only
 dataclasses_transform_meta.py:60:36: error[unknown-argument] Argument `other_name` does not match any known parameter
+dataclasses_transform_meta.py:66:18: error[too-many-positional-arguments] Too many positional arguments: expected 0, got 2
 dataclasses_transform_meta.py:73:6: error[unsupported-operator] Operator `<` is not supported for types `Customer1` and `Customer1`
 dataclasses_transform_meta.py:79:6: error[unsupported-operator] Operator `<` is not supported for types `Customer2` and `Customer2`
+dataclasses_transform_meta.py:83:8: error[missing-argument] No argument provided for required parameter `id`
+dataclasses_transform_meta.py:83:18: error[too-many-positional-arguments] Too many positional arguments: expected 0, got 2
+dataclasses_transform_meta.py:103:1: error[invalid-assignment] Property `id` defined in `Customer3` is read-only
 dataclasses_usage.py:50:6: error[missing-argument] No argument provided for required parameter `unit_price`
 dataclasses_usage.py:51:28: error[invalid-argument-type] Argument is incorrect: Expected `int | float`, found `Literal["price"]`
 dataclasses_usage.py:52:36: error[too-many-positional-arguments] Too many positional arguments: expected 3, got 4
@@ -896,5 +900,5 @@
 typeddicts_usage.py:28:17: error[missing-typed-dict-key] Missing required key 'name' in TypedDict `Movie` constructor
 typeddicts_usage.py:28:18: error[invalid-key] Invalid key access on TypedDict `Movie`: Unknown key "title"
 typeddicts_usage.py:40:24: error[invalid-type-form] The special form `typing.TypedDict` is not allowed in type expressions. Did you mean to use a concrete TypedDict or `collections.abc.Mapping[str, object]` instead?
-Found 897 diagnostics
+Found 901 diagnostics
 WARN A fatal error occurred while checking some files. Not all project files were analyzed. See the diagnostics list above for details.

Copy link
Contributor

github-actions bot commented Oct 9, 2025

mypy_primer results

No ecosystem changes detected ✅
No memory usage changes detected ✅

Copy link
Contributor

github-actions bot commented Oct 9, 2025

ecosystem-analyzer results

No diagnostic changes detected ✅
Full report with detailed diff (timing results)

@sharkdp sharkdp force-pushed the david/dataclass_transform-params-for-metaclass-models branch from ee1ea52 to 60daff8 Compare October 9, 2025 08:56
@sharkdp sharkdp marked this pull request as ready for review October 9, 2025 09:29
@sharkdp sharkdp force-pushed the david/dataclass_transform-params-for-metaclass-models branch from 60daff8 to 755c692 Compare October 9, 2025 10:07
@sharkdp sharkdp force-pushed the david/dataclass_transform-params-for-metaclass-models branch from 755c692 to 1ee1dea Compare October 9, 2025 10:09
Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@sharkdp sharkdp enabled auto-merge (squash) October 9, 2025 13:20
@sharkdp sharkdp merged commit 75f3c0e into main Oct 9, 2025
39 checks passed
@sharkdp sharkdp deleted the david/dataclass_transform-params-for-metaclass-models branch October 9, 2025 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ecosystem-analyzer ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants