From 24c1cf71cbbafbc1c4da107e565611f980018718 Mon Sep 17 00:00:00 2001 From: David Peter Date: Tue, 4 Feb 2025 15:24:50 +0100 Subject: [PATCH] [red-knot] Use unambiguous invalid-syntax-construct for suppression comment test (#15933) ## Summary I experimented with [not trimming trailing newlines in code snippets](https://github.com/astral-sh/ruff/pull/15926#discussion_r1940992090), but since came to the conclusion that the current behavior is better because otherwise, there is no way to write snippets without a trailing newline at all. And when you copy the code from a Markdown snippet in GitHub, you also don't get a trailing newline. I was surprised to see some test failures when I played with this though, and decided to make this test independent from this implementation detail. --- .../resources/mdtest/suppressions/knot_ignore.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/red_knot_python_semantic/resources/mdtest/suppressions/knot_ignore.md b/crates/red_knot_python_semantic/resources/mdtest/suppressions/knot_ignore.md index 1b5b7e146a..fb8f78bd43 100644 --- a/crates/red_knot_python_semantic/resources/mdtest/suppressions/knot_ignore.md +++ b/crates/red_knot_python_semantic/resources/mdtest/suppressions/knot_ignore.md @@ -77,7 +77,8 @@ def test(a: f"f-string type annotation", b: b"byte-string-type-annotation"): ... ```py # error: [invalid-syntax] # error: [unused-ignore-comment] -def test( # knot: ignore +def test($): # knot: ignore + pass ```