[syntax-errors] except* before Python 3.11 (#16446)

Summary
--

One of the simpler ones, just detect the use of `except*` before 3.11.

Test Plan
--

New inline tests.
This commit is contained in:
Brent Westbrook
2025-03-02 13:20:18 -05:00
committed by GitHub
parent 0d615b8765
commit e924ecbdac
9 changed files with 180 additions and 23 deletions

View File

@@ -7,7 +7,7 @@ use rustc_hash::{FxBuildHasher, FxHashSet};
use ruff_python_ast::name::Name;
use ruff_python_ast::{
self as ast, BoolOp, CmpOp, ConversionFlag, Expr, ExprContext, FStringElement, FStringElements,
IpyEscapeKind, Number, Operator, PythonVersion, StringFlags, UnaryOp,
IpyEscapeKind, Number, Operator, StringFlags, UnaryOp,
};
use ruff_text_size::{Ranged, TextLen, TextRange, TextSize};
@@ -2171,9 +2171,7 @@ impl<'src> Parser<'src> {
// # parse_options: { "target-version": "3.8" }
// (x := 1)
if self.options.target_version < PythonVersion::PY38 {
self.add_unsupported_syntax_error(UnsupportedSyntaxErrorKind::Walrus, range);
}
self.add_unsupported_syntax_error(UnsupportedSyntaxErrorKind::Walrus, range);
ast::ExprNamed {
target: Box::new(target),