mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-17 17:10:34 +00:00
[red-knot] Do not show types for literal expressions on hover (#17290)
## Summary Resolves #17289. After this change, Red Knot will no longer show types on hover for `None`, `...`, `True`, `False`, numbers, strings (but not f-strings), and bytes literals. ## Test Plan Unit tests.
This commit is contained in:
parent
a388c73752
commit
34e06f2d17
2 changed files with 71 additions and 1 deletions
|
@ -102,6 +102,19 @@ impl Expr {
|
|||
}
|
||||
|
||||
impl ExprRef<'_> {
|
||||
/// See [`Expr::is_literal_expr`].
|
||||
pub fn is_literal_expr(&self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
ExprRef::StringLiteral(_)
|
||||
| ExprRef::BytesLiteral(_)
|
||||
| ExprRef::NumberLiteral(_)
|
||||
| ExprRef::BooleanLiteral(_)
|
||||
| ExprRef::NoneLiteral(_)
|
||||
| ExprRef::EllipsisLiteral(_)
|
||||
)
|
||||
}
|
||||
|
||||
pub fn precedence(&self) -> OperatorPrecedence {
|
||||
OperatorPrecedence::from(self)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue