Semantic tokens: consistently add the DEFINITION modifier#21521
Merged
MichaReiser merged 1 commit intoastral-sh:mainfrom Nov 19, 2025
Merged
Semantic tokens: consistently add the DEFINITION modifier#21521MichaReiser merged 1 commit intoastral-sh:mainfrom
DEFINITION modifier#21521MichaReiser merged 1 commit intoastral-sh:mainfrom
Conversation
Diagnostic diff on typing conformance testsNo changes detected when running ty on typing conformance tests ✅ |
|
MichaReiser
approved these changes
Nov 19, 2025
Member
MichaReiser
left a comment
There was a problem hiding this comment.
Thank you
Handling augmented assignments the way you do in this PR seems right to me.
Member
|
Can you run the |
There are a few more statements potentially containing definitions than what is currently covered. This commit reviews all the statements and completes the list of those requiring a custom visitor to add the `DEFINITION` modifier for the appropriate tokens.
af6215a to
9fd6b24
Compare
Contributor
Author
|
Whoops, sorry. I even ran them, I just overlooked the output 🤦♂️ |
dcreager
added a commit
that referenced
this pull request
Nov 19, 2025
* origin/main: [ty] Fix flaky tests on macos (#21524) [ty] Add tests for generic implicit type aliases (#21522) [ty] Semantic tokens: consistently add the `DEFINITION` modifier (#21521) Only render hyperlinks for terminals known to support them (#21519) [ty] Keep colorizing `mypy_primer` output (#21515) [ty] Exit with `2` if there's any IO error (#21508) [`ruff`] Fix false positive for complex conversion specifiers in `logging-eager-conversion` (`RUF065`) (#21464) [ty] tighten up handling of subscripts in type expressions (#21503)
dcreager
added a commit
that referenced
this pull request
Nov 19, 2025
* origin/main: [ty] Fix flaky tests on macos (#21524) [ty] Add tests for generic implicit type aliases (#21522) [ty] Semantic tokens: consistently add the `DEFINITION` modifier (#21521) Only render hyperlinks for terminals known to support them (#21519) [ty] Keep colorizing `mypy_primer` output (#21515) [ty] Exit with `2` if there's any IO error (#21508) [`ruff`] Fix false positive for complex conversion specifiers in `logging-eager-conversion` (`RUF065`) (#21464) [ty] tighten up handling of subscripts in type expressions (#21503)
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
When computing semantic tokens, there are a few more statements potentially containing definitions than what is currently covered.
This commit reviews all the statements and completes the list of those requiring a custom visitor to add the
DEFINITIONmodifier for the appropriate tokens.Note: I've not added the
DEFINITIONmodifier to the target of an augmented assignment. A new test makes that explicit. This is consistent with Pylance's behavior, although one could argue that given that all "regular" assignments are marked as definitions, perhaps also the augmented assignments should.Test Plan
Added new tests for each new statement with a custom visitor. When a test was already existing, I've reviewed and applied the diff.