mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 06:11:21 +00:00
Use "python" for markdown code fences in on-hover content (#19082)
Instead of "text". Closes https://github.com/astral-sh/ty/issues/749 We may not want this because the type display implementations are not guaranteed to be valid Python, however, unless they're going to highlight invalid syntax this seems like a better interim value than "text"? I'm not the expert though. See https://github.com/astral-sh/ty/issues/749#issuecomment-3026201114 for prior commentary. edit: Going back further to https://github.com/astral-sh/ruff/pull/17057#discussion_r2028151621 for prior context, it turns out they _do_ highlight invalid syntax in red which is quite unfortunate and probably a blocker here.
This commit is contained in:
parent
352b896c89
commit
9fc04d6bf0
1 changed files with 19 additions and 19 deletions
|
@ -118,7 +118,7 @@ impl fmt::Display for DisplayHoverContent<'_, '_> {
|
||||||
match self.content {
|
match self.content {
|
||||||
HoverContent::Type(ty) => self
|
HoverContent::Type(ty) => self
|
||||||
.kind
|
.kind
|
||||||
.fenced_code_block(ty.display(self.db), "text")
|
.fenced_code_block(ty.display(self.db), "python")
|
||||||
.fmt(f),
|
.fmt(f),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ mod tests {
|
||||||
assert_snapshot!(test.hover(), @r"
|
assert_snapshot!(test.hover(), @r"
|
||||||
Literal[10]
|
Literal[10]
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
```text
|
```python
|
||||||
Literal[10]
|
Literal[10]
|
||||||
```
|
```
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
|
@ -184,7 +184,7 @@ mod tests {
|
||||||
assert_snapshot!(test.hover(), @r"
|
assert_snapshot!(test.hover(), @r"
|
||||||
int
|
int
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
```text
|
```python
|
||||||
int
|
int
|
||||||
```
|
```
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
|
@ -214,7 +214,7 @@ mod tests {
|
||||||
assert_snapshot!(test.hover(), @r"
|
assert_snapshot!(test.hover(), @r"
|
||||||
def foo(a, b) -> Unknown
|
def foo(a, b) -> Unknown
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
```text
|
```python
|
||||||
def foo(a, b) -> Unknown
|
def foo(a, b) -> Unknown
|
||||||
```
|
```
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
|
@ -243,7 +243,7 @@ mod tests {
|
||||||
assert_snapshot!(test.hover(), @r"
|
assert_snapshot!(test.hover(), @r"
|
||||||
bool
|
bool
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
```text
|
```python
|
||||||
bool
|
bool
|
||||||
```
|
```
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
|
@ -274,7 +274,7 @@ mod tests {
|
||||||
assert_snapshot!(test.hover(), @r"
|
assert_snapshot!(test.hover(), @r"
|
||||||
Literal[123]
|
Literal[123]
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
```text
|
```python
|
||||||
Literal[123]
|
Literal[123]
|
||||||
```
|
```
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
|
@ -312,7 +312,7 @@ mod tests {
|
||||||
assert_snapshot!(test.hover(), @r"
|
assert_snapshot!(test.hover(), @r"
|
||||||
(def foo(a, b) -> Unknown) | (def bar(a, b) -> Unknown)
|
(def foo(a, b) -> Unknown) | (def bar(a, b) -> Unknown)
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
```text
|
```python
|
||||||
(def foo(a, b) -> Unknown) | (def bar(a, b) -> Unknown)
|
(def foo(a, b) -> Unknown) | (def bar(a, b) -> Unknown)
|
||||||
```
|
```
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
|
@ -344,7 +344,7 @@ mod tests {
|
||||||
assert_snapshot!(test.hover(), @r"
|
assert_snapshot!(test.hover(), @r"
|
||||||
<module 'lib'>
|
<module 'lib'>
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
```text
|
```python
|
||||||
<module 'lib'>
|
<module 'lib'>
|
||||||
```
|
```
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
|
@ -373,7 +373,7 @@ mod tests {
|
||||||
assert_snapshot!(test.hover(), @r"
|
assert_snapshot!(test.hover(), @r"
|
||||||
T
|
T
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
```text
|
```python
|
||||||
T
|
T
|
||||||
```
|
```
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
|
@ -399,7 +399,7 @@ mod tests {
|
||||||
assert_snapshot!(test.hover(), @r"
|
assert_snapshot!(test.hover(), @r"
|
||||||
@Todo
|
@Todo
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
```text
|
```python
|
||||||
@Todo
|
@Todo
|
||||||
```
|
```
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
|
@ -425,7 +425,7 @@ mod tests {
|
||||||
assert_snapshot!(test.hover(), @r"
|
assert_snapshot!(test.hover(), @r"
|
||||||
@Todo
|
@Todo
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
```text
|
```python
|
||||||
@Todo
|
@Todo
|
||||||
```
|
```
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
|
@ -451,7 +451,7 @@ mod tests {
|
||||||
assert_snapshot!(test.hover(), @r"
|
assert_snapshot!(test.hover(), @r"
|
||||||
Literal[1]
|
Literal[1]
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
```text
|
```python
|
||||||
Literal[1]
|
Literal[1]
|
||||||
```
|
```
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
|
@ -482,7 +482,7 @@ mod tests {
|
||||||
assert_snapshot!(test.hover(), @r"
|
assert_snapshot!(test.hover(), @r"
|
||||||
Literal[1]
|
Literal[1]
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
```text
|
```python
|
||||||
Literal[1]
|
Literal[1]
|
||||||
```
|
```
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
|
@ -512,7 +512,7 @@ mod tests {
|
||||||
assert_snapshot!(test.hover(), @r"
|
assert_snapshot!(test.hover(), @r"
|
||||||
Literal[2]
|
Literal[2]
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
```text
|
```python
|
||||||
Literal[2]
|
Literal[2]
|
||||||
```
|
```
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
|
@ -545,7 +545,7 @@ mod tests {
|
||||||
assert_snapshot!(test.hover(), @r"
|
assert_snapshot!(test.hover(), @r"
|
||||||
Unknown | Literal[1]
|
Unknown | Literal[1]
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
```text
|
```python
|
||||||
Unknown | Literal[1]
|
Unknown | Literal[1]
|
||||||
```
|
```
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
|
@ -574,7 +574,7 @@ mod tests {
|
||||||
assert_snapshot!(test.hover(), @r"
|
assert_snapshot!(test.hover(), @r"
|
||||||
int
|
int
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
```text
|
```python
|
||||||
int
|
int
|
||||||
```
|
```
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
|
@ -602,7 +602,7 @@ mod tests {
|
||||||
assert_snapshot!(test.hover(), @r"
|
assert_snapshot!(test.hover(), @r"
|
||||||
Literal[1]
|
Literal[1]
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
```text
|
```python
|
||||||
Literal[1]
|
Literal[1]
|
||||||
```
|
```
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
|
@ -631,7 +631,7 @@ mod tests {
|
||||||
assert_snapshot!(test.hover(), @r"
|
assert_snapshot!(test.hover(), @r"
|
||||||
int
|
int
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
```text
|
```python
|
||||||
int
|
int
|
||||||
```
|
```
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
|
@ -661,7 +661,7 @@ mod tests {
|
||||||
assert_snapshot!(test.hover(), @r"
|
assert_snapshot!(test.hover(), @r"
|
||||||
str
|
str
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
```text
|
```python
|
||||||
str
|
str
|
||||||
```
|
```
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue