Skip to content

[ty] Preserve qualifiers in functional TypedDicts#24176

Open
charliermarsh wants to merge 1 commit intocharlie/typed-dict-2from
charlie/typed-dict-3
Open

[ty] Preserve qualifiers in functional TypedDicts#24176
charliermarsh wants to merge 1 commit intocharlie/typed-dict-2from
charlie/typed-dict-3

Conversation

@charliermarsh
Copy link
Member

Summary

Part of: astral-sh/ty#3095.

@astral-sh-bot astral-sh-bot bot added the ty Multi-file analysis & type inference label Mar 25, 2026
@astral-sh-bot
Copy link

astral-sh-bot bot commented Mar 25, 2026

Typing conformance results improved 🎉

The percentage of diagnostics emitted that were expected errors increased from 86.36% to 86.46%. The percentage of expected errors that received a diagnostic increased from 81.00% to 81.09%. The number of fully passing files improved from 66/132 to 68/132.

Summary

How 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 (E) are true positives when ty flags the expected location and false negatives when it does not. Optional annotations (E?) are true positives when flagged but true negatives (not false negatives) when not. Tagged annotations (E[tag]) require ty to flag exactly one of the tagged lines; tagged multi-annotations (E[tag+]) allow any number up to the tag count. Flagging unexpected locations counts as a false positive.

Metric Old New Diff Outcome
True Positives 861 862 +1 ⏫ (✅)
False Positives 136 135 -1 ⏬ (✅)
False Negatives 202 201 -1 ⏬ (✅)
Total Diagnostics 1060 1060 +0
Precision 86.36% 86.46% +0.10% ⏫ (✅)
Recall 81.00% 81.09% +0.09% ⏫ (✅)
Passing Files 66/132 68/132 +2 ⏫ (✅)

Test file breakdown

2 files altered
File True Positives False Positives False Negatives Status
typeddicts_readonly.py 6 (+1) ✅ 0 0 (-1) ✅ ✅ Newly Passing 🎉
typeddicts_required.py 4 0 (-1) ✅ 0 ✅ Newly Passing 🎉
Total (all files) 862 (+1) ✅ 135 (-1) ✅ 201 (-1) ✅ 68/132

True positives added (1)

1 diagnostic
Test case Diff

typeddicts_readonly.py:36

+error[invalid-assignment] Cannot assign to key "members" on TypedDict `Band2`: key is marked read-only

False positives removed (1)

1 diagnostic
Test case Diff

typeddicts_required.py:74

-error[missing-typed-dict-key] Missing required key 'predecessor' in TypedDict `RecursiveMovie` constructor

@astral-sh-bot
Copy link

astral-sh-bot bot commented Mar 25, 2026

Memory usage report

Summary

Project Old New Diff Outcome
prefect 711.30MB 717.90MB +0.93% (6.61MB)
sphinx 264.18MB 266.13MB +0.74% (1.96MB)
trio 117.31MB 117.99MB +0.57% (690.38kB)
flake8 47.87MB 48.05MB +0.36% (178.12kB)

Significant changes

Click to expand detailed breakdown

prefect

Name Old New Diff Outcome
infer_definition_types 88.30MB 94.03MB +6.49% (5.73MB)
infer_deferred_types 14.61MB 15.50MB +6.03% (902.12kB)

sphinx

Name Old New Diff Outcome
infer_definition_types 23.59MB 25.27MB +7.13% (1.68MB)
infer_deferred_types 5.61MB 5.89MB +4.95% (284.56kB)

trio

Name Old New Diff Outcome
infer_definition_types 7.49MB 8.04MB +7.34% (562.91kB)
infer_deferred_types 2.38MB 2.50MB +5.23% (127.47kB)

flake8

Name Old New Diff Outcome
infer_definition_types 1.82MB 1.96MB +7.57% (141.34kB)
infer_deferred_types 692.48kB 729.26kB +5.31% (36.78kB)

@astral-sh-bot
Copy link

astral-sh-bot bot commented Mar 25, 2026

ecosystem-analyzer results

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

Full report with detailed diff (timing results)

@charliermarsh charliermarsh marked this pull request as ready for review March 25, 2026 16:28
@carljm carljm removed their request for review March 25, 2026 18:20
@sharkdp sharkdp removed their assignment Mar 25, 2026
@AlexWaygood
Copy link
Member

(looks like there's a fair bit of failing CI on this one rn)

@charliermarsh charliermarsh marked this pull request as draft March 25, 2026 20:56
@charliermarsh charliermarsh marked this pull request as ready for review March 25, 2026 21:12
@charliermarsh charliermarsh force-pushed the charlie/typed-dict-3 branch 2 times, most recently from a3e5ce7 to 3fab758 Compare March 26, 2026 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants