[ty] Reject functional TypedDict with mismatched name#24295
Conversation
Typing conformance results improved 🎉The percentage of diagnostics emitted that were expected errors increased from 86.60% to 86.61%. The percentage of expected errors that received a diagnostic increased from 81.47% to 81.56%. The number of fully passing files improved from 69/132 to 70/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 breakdown1 file altered
True positives added (1)1 diagnostic
|
Memory usage reportMemory usage unchanged ✅ |
|
|
|
||
| let name = if let Some(literal) = name_type.as_string_literal() { | ||
| Name::new(literal.value(db)) | ||
| let name = literal.value(db).to_string(); |
There was a problem hiding this comment.
Minor
| let name = literal.value(db).to_string(); | |
| let name = literal.value(db); |
|
On from typing import TypedDict
X = TypedDict("Y", {})but not for this, which seems just as questionable if (per the typing conformance suite) you think it's important for a type checker to enforce that the from typing import TypedDict
def f(x: str):
Y = TypedDict(x, {})(I still feel like this would be better as a bespoke warning-level diagnostic rather than having it use |
* main: (35 commits) Store definition indexes as u32 (#24307) Avoid re-using symbol in RUF024 fix (#24316) [ty] Add materialization to `Divergent` type (#24255) [ty] Make `Divergent` a top-level type variant (#24252) [ty] Fix nested global and nonlocal lookups through forwarding scopes (#24279) Fetch the cargo-dist binary directly instead of using the installer (#24258) [ty] Fix panic on `list[Annotated[()]]` (#24303) Don't measure the AST deallocation time in parser benchmarks (#24301) Enable CodSpeed's memory benchmarks for simulation benchmarks (#24298) Upgrade imara-diff to 0.2.0 (#24299) [ty] Represent `InitVar` as a special form internally, not a class (#24248) `RUF067`: Allow dunder-named assignments in non-strict mode [`pyupgrade`] UP018 should detect more unnecessarily wrapped literals (UP018) (#24093) [ty] Remove unused `system.glob` method (#24300) [ty] Reject functional TypedDict with mismatched name (#24295) Update Rust crate arc-swap to v1.9.0 (#24292) [ty] Remove unused `@Todo(Functional TypedDicts)` (#24297) Update CodSpeedHQ/action action to v4.12.1 (#24290) Update taiki-e/install-action action to v2.69.6 (#24293) Update Rust crate toml to v1.0.7 (#24289) ...
Summary
Given
BadTypedDict = TypedDict("WrongName", {"name": str}), the conformance test suite suggests we need to raise a diagnostic due to the mismatch betweenBadTypedDictandWrongName.See: #24174 (comment).