[syntax-errors] Limit except* range to * (#16473)

Summary
--
This is a follow-up to #16446 to fix the diagnostic range to point to
the `*` like `pyright` does
(https://github.com/astral-sh/ruff/pull/16446#discussion_r1976900643).

Storing the range in the `ExceptClauseKind::Star` variant feels slightly
awkward, but we don't store the star itself anywhere on the
`ExceptHandler`. And we can't just take `ExceptHandler.start() +
"except".text_len()` because this code appears to be valid:

```python
try: ...
except    *    Error: ...
```

Test Plan
--
Existing tests.
This commit is contained in:
Brent Westbrook 2025-03-04 11:50:09 -05:00 committed by GitHub
parent 1977dda079
commit c8a06a9be8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 94 additions and 16 deletions

View file

@ -1,3 +1,5 @@
# parse_options: {"target-version": "3.10"}
try: ...
except* ValueError: ...
except* KeyError: ...
except * Error: ...