From ba7ed3a6f99aa37c82b888c0ecea3ebf1ba0ec03 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Fri, 18 Jul 2025 07:46:48 -0400 Subject: [PATCH] =?UTF-8?q?[ty]=20Use=20`=E2=80=A6`=20as=20the=20"cut"=20i?= =?UTF-8?q?ndicator=20in=20diagnostic=20rendering=20(#19420)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes ty match ruff's behavior. Specifically, we want to use `…` instead of the default `...` because `...` has special significance in Python. --- crates/ruff_db/src/diagnostic/render.rs | 3 ++- crates/ty/tests/cli/main.rs | 2 +- ..._`async`_comprehensio…_-_Python_3.10_(96aa8ec77d46553d).snap | 2 +- ...atements_-_Accidental_use_of_no…_(b07503f9b773ea61).snap | 6 +++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/ruff_db/src/diagnostic/render.rs b/crates/ruff_db/src/diagnostic/render.rs index 7dbfe650e2..d567e5d5b5 100644 --- a/crates/ruff_db/src/diagnostic/render.rs +++ b/crates/ruff_db/src/diagnostic/render.rs @@ -158,7 +158,8 @@ impl std::fmt::Display for DisplayDiagnostics<'_> { AnnotateRenderer::styled() } else { AnnotateRenderer::plain() - }; + } + .cut_indicator("…"); renderer = renderer .error(stylesheet.error) diff --git a/crates/ty/tests/cli/main.rs b/crates/ty/tests/cli/main.rs index dbab7f0662..5d4152d0e1 100644 --- a/crates/ty/tests/cli/main.rs +++ b/crates/ty/tests/cli/main.rs @@ -660,7 +660,7 @@ fn can_handle_large_binop_expressions() -> anyhow::Result<()> { --> test.py:4:13 | 2 | from typing_extensions import reveal_type - 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... + 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 +… 4 | reveal_type(total) | ^^^^^ `Literal[2000]` | diff --git a/crates/ty_python_semantic/resources/mdtest/snapshots/semantic_syntax_erro…_-_Semantic_syntax_erro…_-_`async`_comprehensio…_-_Python_3.10_(96aa8ec77d46553d).snap b/crates/ty_python_semantic/resources/mdtest/snapshots/semantic_syntax_erro…_-_Semantic_syntax_erro…_-_`async`_comprehensio…_-_Python_3.10_(96aa8ec77d46553d).snap index e1e2deae53..6fd460c56d 100644 --- a/crates/ty_python_semantic/resources/mdtest/snapshots/semantic_syntax_erro…_-_Semantic_syntax_erro…_-_`async`_comprehensio…_-_Python_3.10_(96aa8ec77d46553d).snap +++ b/crates/ty_python_semantic/resources/mdtest/snapshots/semantic_syntax_erro…_-_Semantic_syntax_erro…_-_`async`_comprehensio…_-_Python_3.10_(96aa8ec77d46553d).snap @@ -36,7 +36,7 @@ error[invalid-syntax] --> src/mdtest_snippet.py:6:19 | 4 | async def f(): -5 | # error: 19 [invalid-syntax] "cannot use an asynchronous comprehension inside of a synchronous comprehension on Python 3.10 (synt... +5 | # error: 19 [invalid-syntax] "cannot use an asynchronous comprehension inside of a synchronous comprehension on Python 3.10 (syntax… 6 | return {n: [x async for x in elements(n)] for n in range(3)} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot use an asynchronous comprehension inside of a synchronous comprehension on Python 3.10 (syntax was added in 3.11) 7 | async def test(): diff --git a/crates/ty_python_semantic/resources/mdtest/snapshots/sync.md_-_With_statements_-_Accidental_use_of_no…_(b07503f9b773ea61).snap b/crates/ty_python_semantic/resources/mdtest/snapshots/sync.md_-_With_statements_-_Accidental_use_of_no…_(b07503f9b773ea61).snap index b8243d669f..175e8ca13f 100644 --- a/crates/ty_python_semantic/resources/mdtest/snapshots/sync.md_-_With_statements_-_Accidental_use_of_no…_(b07503f9b773ea61).snap +++ b/crates/ty_python_semantic/resources/mdtest/snapshots/sync.md_-_With_statements_-_Accidental_use_of_no…_(b07503f9b773ea61).snap @@ -41,7 +41,7 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/with/sync.md error[invalid-context-manager]: Object of type `Manager` cannot be used with `with` because it does not implement `__enter__` and `__exit__` --> src/mdtest_snippet.py:6:6 | -5 | # error: [invalid-context-manager] "Object of type `Manager` cannot be used with `with` because it does not implement `__enter__` and... +5 | # error: [invalid-context-manager] "Object of type `Manager` cannot be used with `with` because it does not implement `__enter__` and `… 6 | with Manager(): | ^^^^^^^^^ 7 | ... @@ -57,7 +57,7 @@ info: rule `invalid-context-manager` is enabled by default error[invalid-context-manager]: Object of type `Manager` cannot be used with `with` because it does not implement `__enter__` and `__exit__` --> src/mdtest_snippet.py:13:6 | -12 | # error: [invalid-context-manager] "Object of type `Manager` cannot be used with `with` because it does not implement `__enter__` an... +12 | # error: [invalid-context-manager] "Object of type `Manager` cannot be used with `with` because it does not implement `__enter__` and … 13 | with Manager(): | ^^^^^^^^^ 14 | ... @@ -73,7 +73,7 @@ info: rule `invalid-context-manager` is enabled by default error[invalid-context-manager]: Object of type `Manager` cannot be used with `with` because it does not implement `__enter__` and `__exit__` --> src/mdtest_snippet.py:20:6 | -19 | # error: [invalid-context-manager] "Object of type `Manager` cannot be used with `with` because it does not implement `__enter__` an... +19 | # error: [invalid-context-manager] "Object of type `Manager` cannot be used with `with` because it does not implement `__enter__` and … 20 | with Manager(): | ^^^^^^^^^ 21 | ...