MCPcopy Create free account
hub / github.com/astral-sh/ruff / check_tuple_unpacking

Method check_tuple_unpacking

crates/ruff_python_parser/src/parser/statement.rs:502–521  ·  view source on GitHub ↗

Report [`UnsupportedSyntaxError`]s for each starred element in `expr` if it is an unparenthesized tuple. This method can be used to check for tuple unpacking in `return`, `yield`, and `for` statements, which are only allowed after [Python 3.8] and [Python 3.9], respectively. [Python 3.8]: https://github.com/python/cpython/issues/76298 [Python 3.9]: https://github.com/python/cpython/issues/90881

(&mut self, expr: &Expr, kind: UnsupportedSyntaxErrorKind)

Source from the content-addressed store, hash-verified

500 /// [Python 3.8]: https://github.com/python/cpython/issues/76298
501 /// [Python 3.9]: https://github.com/python/cpython/issues/90881
502 pub(super) fn check_tuple_unpacking(&mut self, expr: &Expr, kind: UnsupportedSyntaxErrorKind) {
503 if kind.is_supported(self.options.target_version) {
504 return;
505 }
506
507 let Expr::Tuple(ast::ExprTuple {
508 elts,
509 parenthesized: false,
510 ..
511 }) = expr
512 else {
513 return;
514 };
515
516 for elt in elts {
517 if elt.is_starred_expr() {
518 self.add_unsupported_syntax_error(kind, elt.range());
519 }
520 }
521 }
522
523 /// Parses a `raise` statement.
524 ///

Callers 3

parse_for_statementMethod · 0.80

Calls 4

is_supportedMethod · 0.80
is_starred_exprMethod · 0.80
rangeMethod · 0.45

Tested by

no test coverage detected