mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-31 23:57:54 +00:00
[syntax-errors] Assignment expressions before Python 3.8 (#16383)
## Summary This PR is the first in a series derived from https://github.com/astral-sh/ruff/pull/16308, each of which add support for detecting one version-related syntax error from https://github.com/astral-sh/ruff/issues/6591. This one should be the largest because it also includes the addition of the `Parser::add_unsupported_syntax_error` method Otherwise I think the general structure will be the same for each syntax error: * Detecting the error in the parser * Inline parser tests for the new error * New ruff CLI tests for the new error ## Test Plan As noted above, there are new inline parser tests, as well as new ruff CLI tests. Once https://github.com/astral-sh/ruff/pull/16379 is resolved, there should also be new mdtests for red-knot, but this PR does not currently include those.
This commit is contained in:
parent
ba44e9de13
commit
4431978262
9 changed files with 182 additions and 28 deletions
|
@ -17,7 +17,7 @@ use crate::parser::{
|
|||
};
|
||||
use crate::token::{TokenKind, TokenValue};
|
||||
use crate::token_set::TokenSet;
|
||||
use crate::{Mode, ParseErrorType, UnsupportedSyntaxError, UnsupportedSyntaxErrorKind};
|
||||
use crate::{Mode, ParseErrorType, UnsupportedSyntaxErrorKind};
|
||||
|
||||
use super::expression::ExpressionContext;
|
||||
use super::Parenthesized;
|
||||
|
@ -2278,11 +2278,7 @@ impl<'src> Parser<'src> {
|
|||
// pass
|
||||
|
||||
if self.options.target_version < PythonVersion::PY310 {
|
||||
self.unsupported_syntax_errors.push(UnsupportedSyntaxError {
|
||||
kind: UnsupportedSyntaxErrorKind::MatchBeforePy310,
|
||||
range: match_range,
|
||||
target_version: self.options.target_version,
|
||||
});
|
||||
self.add_unsupported_syntax_error(UnsupportedSyntaxErrorKind::Match, match_range);
|
||||
}
|
||||
|
||||
ast::StmtMatch {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue