[ty] Preserve qualifiers in functional TypedDicts#24226
[ty] Preserve qualifiers in functional TypedDicts#24226charliermarsh merged 1 commit intocharlie/typed-dict-1from
Conversation
|
This is a revival of #24176 which was accidentally merged. |
Typing conformance results improved 🎉The percentage of diagnostics emitted that were expected errors increased from 86.50% to 86.60%. The percentage of expected errors that received a diagnostic increased from 81.37% to 81.47%. The number of fully passing files improved from 67/132 to 69/132. SummaryHow are test cases classified?Each test case represents one expected error annotation or a group of annotations sharing a tag. Counts are per test case, not per diagnostic — multiple diagnostics on the same line count as one. Required annotations (
Test file breakdown2 files altered
True positives added (1)1 diagnostic
False positives removed (1)1 diagnostic
Optional Diagnostics Changed (2)2 diagnostics
|
Memory usage reportSummary
Significant changesClick to expand detailed breakdownprefect
sphinx
trio
flake8
|
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-await |
0 | 40 | 0 |
missing-typed-dict-key |
2 | 10 | 0 |
invalid-argument-type |
2 | 2 | 0 |
invalid-return-type |
0 | 2 | 0 |
| Total | 4 | 54 | 0 |
Changes in flaky projects detected. Raw diff output excludes flaky projects; see the HTML report for details.
Raw diff (17 changes)
archinstall (https://github.com/archlinux/archinstall)
- archinstall/lib/models/users.py:176:10 error[missing-typed-dict-key] Missing required key '!password' in TypedDict `UserSerialization` constructor
- archinstall/lib/models/users.py:176:10 error[invalid-return-type] Return type does not match returned value: expected `UserSerialization`, found `dict[str, str | Unknown | None | bool | list[str]]`
meson (https://github.com/mesonbuild/meson)
- mesonbuild/scripts/depscan.py:170:26 error[missing-typed-dict-key] Missing required key 'outputs' in TypedDict `Rule` constructor
- mesonbuild/scripts/depscan.py:182:45 error[invalid-argument-type] Argument to bound method `append` is incorrect: Expected `Require`, found `dict[str, str]`
- mesonbuild/scripts/depscan.py:182:45 error[missing-typed-dict-key] Missing required key 'compiled-module-path' in TypedDict `Require` constructor
- mesonbuild/scripts/depscan.py:182:45 error[missing-typed-dict-key] Missing required key 'lookup-method' in TypedDict `Require` constructor
- mesonbuild/scripts/depscan.py:182:45 error[missing-typed-dict-key] Missing required key 'source-path' in TypedDict `Require` constructor
- mesonbuild/scripts/depscan.py:182:45 error[missing-typed-dict-key] Missing required key 'unique-on-source-path' in TypedDict `Require` constructor
- mesonbuild/scripts/depscan.py:192:41 error[invalid-argument-type] Argument to bound method `append` is incorrect: Expected `Provide`, found `dict[str, str | Unknown]`
- mesonbuild/scripts/depscan.py:192:41 error[missing-typed-dict-key] Missing required key 'is-interface' in TypedDict `Provide` constructor
- mesonbuild/scripts/depscan.py:192:41 error[missing-typed-dict-key] Missing required key 'unique-on-source-path' in TypedDict `Provide` constructor
+ unittests/cargotests.py:333:33 error[invalid-argument-type] Argument to bound method `from_raw` is incorrect: Expected `Manifest`, found `dict[str, dict[str, str] | FromWorkspace]`
+ unittests/cargotests.py:333:45 error[missing-typed-dict-key] Missing required key 'version' in TypedDict `Package` constructor
+ unittests/cargotests.py:340:33 error[invalid-argument-type] Argument to bound method `from_raw` is incorrect: Expected `Manifest`, found `dict[str, dict[str, str]]`
+ unittests/cargotests.py:340:45 error[missing-typed-dict-key] Missing required key 'version' in TypedDict `Package` constructor
operator (https://github.com/canonical/operator)
- ops/pebble.py:2102:32 error[missing-typed-dict-key] Missing required key 'basic' in TypedDict `IdentityDict` constructor
- ops/pebble.py:2102:32 error[missing-typed-dict-key] Missing required key 'local' in TypedDict `IdentityDict` constructor
Merging this PR will not alter performance
Comparing Footnotes
|
eef123e to
a92e311
Compare
1b18838 to
090a0f0
Compare
a92e311 to
0ba749a
Compare
090a0f0 to
6f3c8ad
Compare
0ba749a to
bf96ce0
Compare
6f3c8ad to
328bd5c
Compare
bf96ce0 to
31d27b9
Compare
328bd5c to
50d1ded
Compare
50d1ded to
5ba83c8
Compare
31d27b9 to
e90ed9c
Compare
5ba83c8 to
967e0d5
Compare
e90ed9c to
0792b00
Compare
## Summary This PR adds basic support for functional TypedDict construction, including recursive TypedDicts. The intent is to follow the patterns we've established for functional NamedTuple and `type(...)` calls as closely as we can. There are two follow-up PRs that were carved out to make them easier to review: - #24226 - #24227 (My intent is to merge the stack once all three are approved. E.g., the new false positive in the ecosystem test is fixed in #24176.) Part of: astral-sh/ty#3095. --------- Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
Summary
Part of: astral-sh/ty#3095.