Goto definition, declaration, find references for typed dict and named tuple initializers#24897
Merged
MichaReiser merged 6 commits intomainfrom Apr 28, 2026
Merged
Goto definition, declaration, find references for typed dict and named tuple initializers#24897MichaReiser merged 6 commits intomainfrom
MichaReiser merged 6 commits intomainfrom
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 88.70%. The percentage of expected errors that received a diagnostic held steady at 84.63%. The number of fully passing files held steady at 84/134. |
Memory usage reportSummary
Significant changesClick to expand detailed breakdownprefect
sphinx
trio
flake8
|
|
933b26f to
0f0e51b
Compare
MichaReiser
commented
Apr 28, 2026
| | | ||
| 7 | g: str | ||
| 8 | | ||
| 9 | def __init__(self, f: int) -> None: ... |
Member
Author
There was a problem hiding this comment.
This matches pylance's behavior
5338b96 to
728d186
Compare
charliermarsh
approved these changes
Apr 28, 2026
Member
charliermarsh
left a comment
There was a problem hiding this comment.
Very nice (and agree that this is a good tradeoff).
728d186 to
6cb41ac
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes goto definition, find references, rename, etc for synthesized methods and constructor calls.
Each
Parameternow stores its definition, which the LSP can use. This allows synthesized functions and methods to set the parameter's definition to e.g. a TypedDict field.The downside of this approach is that
Parametergrows in size, as shown in the memory usage report. I consider the increase acceptable, given that it's ~0.10%.I also decided to use
parameter.definitionfor all parameters, not just synthesized methods. This simplifies our implementation and is free, because the memory increase is not from how many instances store aDefinition, but that we need theParameter.definitionfield in the first place.Fixes astral-sh/ty#1881
Fixes astral-sh/ty#3207
Fixes astral-sh/ty#3348
Fixes astral-sh/ty#3349
Test
Added integration tests