mirror of
https://github.com/astral-sh/ruff
synced 2026-01-23 14:30:53 -05:00
[syntax-errors] Named expressions in decorators before Python 3.9 (#16386)
Summary -- This PR detects the relaxed grammar for decorators proposed in [PEP 614](https://peps.python.org/pep-0614/) on Python 3.8 and lower. The 3.8 grammar for decorators is [here](https://docs.python.org/3.8/reference/compound_stmts.html#grammar-token-decorators): ``` decorators ::= decorator+ decorator ::= "@" dotted_name ["(" [argument_list [","]] ")"] NEWLINE dotted_name ::= identifier ("." identifier)* ``` in contrast to the current grammar [here](https://docs.python.org/3/reference/compound_stmts.html#grammar-token-python-grammar-decorators) ``` decorators ::= decorator+ decorator ::= "@" assignment_expression NEWLINE assignment_expression ::= [identifier ":="] expression ``` Test Plan -- New inline parser tests.
This commit is contained in:
@@ -632,7 +632,7 @@ impl<'src> Parser<'src> {
|
||||
/// If the parser isn't position at a `(` token.
|
||||
///
|
||||
/// See: <https://docs.python.org/3/reference/expressions.html#calls>
|
||||
fn parse_call_expression(&mut self, func: Expr, start: TextSize) -> ast::ExprCall {
|
||||
pub(super) fn parse_call_expression(&mut self, func: Expr, start: TextSize) -> ast::ExprCall {
|
||||
let arguments = self.parse_arguments();
|
||||
|
||||
ast::ExprCall {
|
||||
|
||||
Reference in New Issue
Block a user