Skip to content

Commit ba7ed3a

Browse files
authored
[ty] Use as the "cut" indicator in diagnostic rendering (#19420)
This makes ty match ruff's behavior. Specifically, we want to use `…` instead of the default `...` because `...` has special significance in Python.
1 parent 39b4183 commit ba7ed3a

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

crates/ruff_db/src/diagnostic/render.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ impl std::fmt::Display for DisplayDiagnostics<'_> {
158158
AnnotateRenderer::styled()
159159
} else {
160160
AnnotateRenderer::plain()
161-
};
161+
}
162+
.cut_indicator("…");
162163

163164
renderer = renderer
164165
.error(stylesheet.error)

crates/ty/tests/cli/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ fn can_handle_large_binop_expressions() -> anyhow::Result<()> {
660660
--> test.py:4:13
661661
|
662662
2 | from typing_extensions import reveal_type
663-
3 | total = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1...
663+
3 | total = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 +…
664664
4 | reveal_type(total)
665665
| ^^^^^ `Literal[2000]`
666666
|

crates/ty_python_semantic/resources/mdtest/snapshots/semantic_syntax_erro…_-_Semantic_syntax_erro…_-_`async`_comprehensio…_-_Python_3.10_(96aa8ec77d46553d).snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ error[invalid-syntax]
3636
--> src/mdtest_snippet.py:6:19
3737
|
3838
4 | async def f():
39-
5 | # error: 19 [invalid-syntax] "cannot use an asynchronous comprehension inside of a synchronous comprehension on Python 3.10 (synt...
39+
5 | # error: 19 [invalid-syntax] "cannot use an asynchronous comprehension inside of a synchronous comprehension on Python 3.10 (syntax…
4040
6 | return {n: [x async for x in elements(n)] for n in range(3)}
4141
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot use an asynchronous comprehension inside of a synchronous comprehension on Python 3.10 (syntax was added in 3.11)
4242
7 | async def test():

crates/ty_python_semantic/resources/mdtest/snapshots/sync.md_-_With_statements_-_Accidental_use_of_no…_(b07503f9b773ea61).snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/with/sync.md
4141
error[invalid-context-manager]: Object of type `Manager` cannot be used with `with` because it does not implement `__enter__` and `__exit__`
4242
--> src/mdtest_snippet.py:6:6
4343
|
44-
5 | # error: [invalid-context-manager] "Object of type `Manager` cannot be used with `with` because it does not implement `__enter__` and...
44+
5 | # error: [invalid-context-manager] "Object of type `Manager` cannot be used with `with` because it does not implement `__enter__` and `
4545
6 | with Manager():
4646
| ^^^^^^^^^
4747
7 | ...
@@ -57,7 +57,7 @@ info: rule `invalid-context-manager` is enabled by default
5757
error[invalid-context-manager]: Object of type `Manager` cannot be used with `with` because it does not implement `__enter__` and `__exit__`
5858
--> src/mdtest_snippet.py:13:6
5959
|
60-
12 | # error: [invalid-context-manager] "Object of type `Manager` cannot be used with `with` because it does not implement `__enter__` an...
60+
12 | # error: [invalid-context-manager] "Object of type `Manager` cannot be used with `with` because it does not implement `__enter__` and
6161
13 | with Manager():
6262
| ^^^^^^^^^
6363
14 | ...
@@ -73,7 +73,7 @@ info: rule `invalid-context-manager` is enabled by default
7373
error[invalid-context-manager]: Object of type `Manager` cannot be used with `with` because it does not implement `__enter__` and `__exit__`
7474
--> src/mdtest_snippet.py:20:6
7575
|
76-
19 | # error: [invalid-context-manager] "Object of type `Manager` cannot be used with `with` because it does not implement `__enter__` an...
76+
19 | # error: [invalid-context-manager] "Object of type `Manager` cannot be used with `with` because it does not implement `__enter__` and
7777
20 | with Manager():
7878
| ^^^^^^^^^
7979
21 | ...

0 commit comments

Comments
 (0)