[syntax-errors] Star expression in index before Python 3.11 (#16544)

Summary
--

This PR detects tuple unpacking expressions in index/subscript
expressions before Python 3.11.

Test Plan
--

New inline tests
This commit is contained in:
Brent Westbrook 2025-03-14 10:51:34 -04:00 committed by GitHub
parent 2cd25ef641
commit 4f2851982d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 933 additions and 0 deletions

View file

@ -0,0 +1,7 @@
# parse_options: {"target-version": "3.10"}
lst[*index] # simple index
class Array(Generic[DType, *Shape]): ... # motivating example from the PEP
lst[a, *b, c] # different positions
lst[a, b, *c] # different positions
lst[*a, *b] # multiple unpacks
array[3:5, *idxs] # mixed with slices

View file

@ -0,0 +1 @@
array[*start:*end]

View file

@ -0,0 +1,7 @@
# parse_options: {"target-version": "3.11"}
lst[*index] # simple index
class Array(Generic[DType, *Shape]): ... # motivating example from the PEP
lst[a, *b, c] # different positions
lst[a, b, *c] # different positions
lst[*a, *b] # multiple unpacks
array[3:5, *idxs] # mixed with slices