From b6445de34d2aee107927c1a97f9a8367f48c2ffe Mon Sep 17 00:00:00 2001 From: Jonathan Plasse <13716151+JonathanPlasse@users.noreply.github.com> Date: Thu, 23 Feb 2023 09:58:36 +0100 Subject: [PATCH] Fix ExceptionGroup F821 false positive --- crates/ruff/resources/test/fixtures/pyflakes/F821_10.py | 4 ++++ crates/ruff/src/rules/pyflakes/mod.rs | 1 + .../ruff__rules__pyflakes__tests__F821_F821_10.py.snap | 6 ++++++ crates/ruff_python/src/builtins.rs | 1 + 4 files changed, 12 insertions(+) create mode 100644 crates/ruff/resources/test/fixtures/pyflakes/F821_10.py create mode 100644 crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_10.py.snap diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F821_10.py b/crates/ruff/resources/test/fixtures/pyflakes/F821_10.py new file mode 100644 index 0000000000..1c43827057 --- /dev/null +++ b/crates/ruff/resources/test/fixtures/pyflakes/F821_10.py @@ -0,0 +1,4 @@ +try: + pass +except ExceptionGroup: + pass diff --git a/crates/ruff/src/rules/pyflakes/mod.rs b/crates/ruff/src/rules/pyflakes/mod.rs index be0b1cf7c1..6db17a0888 100644 --- a/crates/ruff/src/rules/pyflakes/mod.rs +++ b/crates/ruff/src/rules/pyflakes/mod.rs @@ -102,6 +102,7 @@ mod tests { #[test_case(Rule::UndefinedName, Path::new("F821_7.py"); "F821_7")] #[test_case(Rule::UndefinedName, Path::new("F821_8.pyi"); "F821_8")] #[test_case(Rule::UndefinedName, Path::new("F821_9.py"); "F821_9")] + #[test_case(Rule::UndefinedName, Path::new("F821_10.py"); "F821_10")] #[test_case(Rule::UndefinedExport, Path::new("F822_0.py"); "F822_0")] #[test_case(Rule::UndefinedExport, Path::new("F822_1.py"); "F822_1")] #[test_case(Rule::UndefinedExport, Path::new("F822_2.py"); "F822_2")] diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_10.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_10.py.snap new file mode 100644 index 0000000000..bd5537b631 --- /dev/null +++ b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_10.py.snap @@ -0,0 +1,6 @@ +--- +source: crates/ruff/src/rules/pyflakes/mod.rs +expression: diagnostics +--- +[] + diff --git a/crates/ruff_python/src/builtins.rs b/crates/ruff_python/src/builtins.rs index 497e3fb281..fe376fd3f3 100644 --- a/crates/ruff_python/src/builtins.rs +++ b/crates/ruff_python/src/builtins.rs @@ -17,6 +17,7 @@ pub const BUILTINS: &[&str] = &[ "Ellipsis", "EnvironmentError", "Exception", + "ExceptionGroup", "False", "FileExistsError", "FileNotFoundError",