mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-22 03:15:44 +00:00
Make syntax error for unparenthesized except tuples version specific to before 3.14 (#17660)
What it says on the tin 😄
This commit is contained in:
parent
31e6576971
commit
3c460a7b9a
9 changed files with 526 additions and 274 deletions
|
@ -1581,25 +1581,50 @@ impl<'src> Parser<'src> {
|
|||
..
|
||||
})
|
||||
) {
|
||||
// test_err except_stmt_unparenthesized_tuple
|
||||
// try:
|
||||
// pass
|
||||
// except x, y:
|
||||
// pass
|
||||
// except x, y as exc:
|
||||
// pass
|
||||
// try:
|
||||
// pass
|
||||
// except* x, y:
|
||||
// pass
|
||||
// except* x, y as eg:
|
||||
// pass
|
||||
self.add_error(
|
||||
ParseErrorType::OtherError(
|
||||
"Multiple exception types must be parenthesized".to_string(),
|
||||
),
|
||||
&parsed_expr,
|
||||
);
|
||||
if self.at(TokenKind::As) {
|
||||
// test_err except_stmt_unparenthesized_tuple_as
|
||||
// try:
|
||||
// pass
|
||||
// except x, y as exc:
|
||||
// pass
|
||||
// try:
|
||||
// pass
|
||||
// except* x, y as eg:
|
||||
// pass
|
||||
self.add_error(
|
||||
ParseErrorType::OtherError(
|
||||
"Multiple exception types must be parenthesized when using `as`"
|
||||
.to_string(),
|
||||
),
|
||||
&parsed_expr,
|
||||
);
|
||||
} else {
|
||||
// test_err except_stmt_unparenthesized_tuple_no_as_py313
|
||||
// # parse_options: {"target-version": "3.13"}
|
||||
// try:
|
||||
// pass
|
||||
// except x, y:
|
||||
// pass
|
||||
// try:
|
||||
// pass
|
||||
// except* x, y:
|
||||
// pass
|
||||
|
||||
// test_ok except_stmt_unparenthesized_tuple_no_as_py314
|
||||
// # parse_options: {"target-version": "3.14"}
|
||||
// try:
|
||||
// pass
|
||||
// except x, y:
|
||||
// pass
|
||||
// try:
|
||||
// pass
|
||||
// except* x, y:
|
||||
// pass
|
||||
self.add_unsupported_syntax_error(
|
||||
UnsupportedSyntaxErrorKind::UnparenthesizedExceptionTypes,
|
||||
parsed_expr.range(),
|
||||
);
|
||||
}
|
||||
}
|
||||
Some(Box::new(parsed_expr.expr))
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue