[ty] Disallow read-only fields in TypedDict updates#24128
Conversation
6e59686 to
ae365b3
Compare
ae365b3 to
980c653
Compare
60d3bcc to
ede055d
Compare
Typing conformance results improved 🎉The percentage of diagnostics emitted that were expected errors increased from 85.38% to 85.39%. The percentage of expected errors that received a diagnostic increased from 78.70% to 78.79%. The number of fully passing files improved from 64/132 to 65/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 ✅ |
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-await |
40 | 0 | 0 |
invalid-return-type |
1 | 0 | 0 |
| Total | 41 | 0 | 0 |
Changes in flaky projects detected. Raw diff output excludes flaky projects; see the HTML report for details.
Merging this PR will not alter performance
Comparing Footnotes
|
8952548 to
9d0c63b
Compare
ede055d to
70b4f79
Compare
| let mut field = field.clone().with_required(false); | ||
| if field.is_read_only() { | ||
| field.declared_ty = Type::Never; | ||
| } |
There was a problem hiding this comment.
I'm a little confused wny we need to keep the field present with Never here, it seems like TypedDict subtyping should handle the Never case correctly, and if not we should fix it there instead of here (i.e., that a TypedDict A { id: NotRequired[Never] } is a subtype of B {}. Is there a reason you special-cased it here, is this a pattern that shows up in the ecosystem?
There was a problem hiding this comment.
This is the argument type for update. If we omit this, it'll accept these fields. Maybe I'm misunderstanding?
* main: [ty] make `test-case` a dev-dependency (#24187) [ty] implement cycle normalization for more types to prevent too-many-cycle panics (#24061) [ty] Silence all diagnostics in unreachable code (#24179) [ty] Intern `InferableTypeVars` (#24161) Implement unnecessary-if (RUF050) (#24114) Recognize `Self` annotation and `self` assignment in SLF001 (#24144) Bump the npm version before publish (#24178) [ty] Disallow Self in metaclass and static methods (#23231) Use trusted publishing for NPM packages (#24171) [ty] Respect non-explicitly defined dataclass params (#24170) Add RUF072: warn when using operator on an f-string (#24162) [ty] Check return type of generator functions (#24026) Implement useless-finally (RUF-072) (#24165) [ty] Add test for a dataclass with a default field converter (#24169) [ty] Dataclass field converters (#23088) [flake8-bandit] Treat sys.executable as trusted input in S603 (#24106) [ty] Add support for `typing.Concatenate` (#23689) `ASYNC115`: autofix to use full qualified `anyio.lowlevel` import (#24166) [ty] Disallow read-only fields in TypedDict updates (#24128) Speed up diagnostic rendering (#24146)
Summary
Closes astral-sh/ty#3098.