mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-18 01:20:40 +00:00
[syntax-errors] Parenthesized keyword argument names after Python 3.8 (#16482)
Summary -- Unlike the other syntax errors detected so far, parenthesized keyword arguments are only allowed *before* 3.8. It sounds like they were only accidentally allowed before that [^1]. As an aside, you get a pretty confusing error from Python for this, so it's nice that we can catch it: ```pycon >>> def f(**kwargs): ... ... f((a)=1) ... File "<python-input-0>", line 2 f((a)=1) ^^^ SyntaxError: expression cannot contain assignment, perhaps you meant "=="? >>> ``` Test Plan -- Inline tests. [^1]: https://github.com/python/cpython/issues/78822
This commit is contained in:
parent
6c14225c66
commit
b3c884f4f3
8 changed files with 319 additions and 22 deletions
|
@ -441,7 +441,7 @@ impl<'src> Parser<'src> {
|
|||
/// Add an [`UnsupportedSyntaxError`] with the given [`UnsupportedSyntaxErrorKind`] and
|
||||
/// [`TextRange`] if its minimum version is less than [`Parser::target_version`].
|
||||
fn add_unsupported_syntax_error(&mut self, kind: UnsupportedSyntaxErrorKind, range: TextRange) {
|
||||
if self.options.target_version < kind.minimum_version() {
|
||||
if kind.is_unsupported(self.options.target_version) {
|
||||
self.unsupported_syntax_errors.push(UnsupportedSyntaxError {
|
||||
kind,
|
||||
range,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue