From d233adf92bda004a9b20bd1b13669f4e173a2c51 Mon Sep 17 00:00:00 2001 From: Brent Westbrook Date: Mon, 8 Dec 2025 14:55:03 -0500 Subject: [PATCH] annotate tests with expected results, add module-level error case --- .../fixtures/semantic_errors/annotated_global.py | 15 +++++++++------ ...tic_syntax_error_annotated_global.py_3.14.snap | 8 ++++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/crates/ruff_linter/resources/test/fixtures/semantic_errors/annotated_global.py b/crates/ruff_linter/resources/test/fixtures/semantic_errors/annotated_global.py index 2614c60e4a..581beed7f3 100644 --- a/crates/ruff_linter/resources/test/fixtures/semantic_errors/annotated_global.py +++ b/crates/ruff_linter/resources/test/fixtures/semantic_errors/annotated_global.py @@ -1,27 +1,30 @@ a: int = 1 def f1(): global a - a: str = "foo" + a: str = "foo" # error b: int = 1 def outer(): def inner(): global b - b: str = "nested" + b: str = "nested" # error c: int = 1 def f2(): global c - c: list[str] = [] + c: list[str] = [] # error d: int = 1 def f3(): global d - d: str + d: str # error e: int = 1 def f4(): - e: str = "happy" + e: str = "happy" # okay global f -f: int = 1 \ No newline at end of file +f: int = 1 # okay + +g: int = 1 +global g # error diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_annotated_global.py_3.14.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_annotated_global.py_3.14.snap index ae70243ad1..c8d3eb32f6 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_annotated_global.py_3.14.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_annotated_global.py_3.14.snap @@ -6,7 +6,7 @@ invalid-syntax: annotated name `a` can't be global | 2 | def f1(): 3 | global a -4 | a: str = "foo" +4 | a: str = "foo" # error | ^ 5 | 6 | b: int = 1 @@ -17,7 +17,7 @@ invalid-syntax: annotated name `b` can't be global | 8 | def inner(): 9 | global b -10 | b: str = "nested" +10 | b: str = "nested" # error | ^ 11 | 12 | c: int = 1 @@ -28,7 +28,7 @@ invalid-syntax: annotated name `c` can't be global | 13 | def f2(): 14 | global c -15 | c: list[str] = [] +15 | c: list[str] = [] # error | ^ 16 | 17 | d: int = 1 @@ -39,7 +39,7 @@ invalid-syntax: annotated name `d` can't be global | 18 | def f3(): 19 | global d -20 | d: str +20 | d: str # error | ^ 21 | 22 | e: int = 1