[syntax-errors] Star annotations before Python 3.11 (#16545)

Summary
--

This is closely related to (and stacked on)
https://github.com/astral-sh/ruff/pull/16544 and detects star
annotations in function definitions.

I initially called the variant `StarExpressionInAnnotation` to mirror
`StarExpressionInIndex`, but I realized it's not really a "star
expression" in this position and renamed it. `StarAnnotation` seems in
line with the PEP.

Test Plan
--

Two new inline tests. It looked like there was pretty good existing
coverage of this syntax, so I just added simple examples to test the
version cutoff.
This commit is contained in:
Brent Westbrook 2025-03-14 11:20:44 -04:00 committed by GitHub
parent 4f2851982d
commit 6311412373
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 199 additions and 2 deletions

View file

@ -0,0 +1,2 @@
# parse_options: {"target-version": "3.11"}
def foo(*args: *Ts): ...