[ty] Show LiteralString when hovering the inline of a literal string#25373
Merged
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 89.52%. The percentage of expected errors that received a diagnostic held steady at 86.99%. The number of fully passing files held steady at 90/134. |
Memory usage reportMemory usage unchanged ✅ |
|
AlexWaygood
approved these changes
May 24, 2026
| string.display_with(self.db, self.settings.clone()), | ||
| ) | ||
| } | ||
| // an alternative would be to use `Type::SpecialForm(SpecialFormType::LiteralString)` here, |
Member
There was a problem hiding this comment.
I'd lean towards updating the comment to explain why we show the docs for LiteralString instead of str here (your reasoning in the PR description is strong) rather than just deleting it
anishgirianish
pushed a commit
to anishgirianish/ruff
that referenced
this pull request
May 28, 2026
astral-sh#25373) ## Summary Today, ty showed the hover for `str` when hovering the inlay of a `LiteralString` type: ```py from typing import LiteralString def my_func(x: LiteralString): y[: LiteralString] = x my_func(x="hello") ``` Hovering the inlay of `y` (`[: LiteralString]` is the inlay) showed the hover of `str`. We argued in astral-sh#21548 that `str` is generally the more useful type in this position. I sort of agree, but I think it's more important that the inlay and the hover show the same type. I also think that it's important that the hover is consistent with when we "bake" the inlay, e.g. hovering `LiteralString` now also shows `LiteralString` and not `str` ```py from typing import LiteralString def my_func(x: LiteralString): y: LiteralString = x my_func(x="hello") ``` Closes astral-sh/ty#2860 ## Test Plan Updated test
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
Today, ty showed the hover for
strwhen hovering the inlay of aLiteralStringtype:Hovering the inlay of
y([: LiteralString]is the inlay) showed the hover ofstr.We argued in #21548 that
stris generally the more useful type in this position. I sort of agree, but I think it's more important that the inlay and the hover show the same type. I also think that it's important that the hover is consistent with when we "bake" the inlay, e.g. hoveringLiteralStringnow also showsLiteralStringand notstrCloses astral-sh/ty#2860
Test Plan
Updated test