Commit 42cbce5
authored
[syntax-errors] Fix star annotation before Python 3.11 (#16878)
Summary
--
Fixes #16874. I previously emitted a syntax error when starred
annotations were _allowed_ rather than when they were actually used.
This caused false positives for any starred parameter name because these
are allowed to have starred annotations but not required to. The fix is
to check if the annotation is actually starred after parsing it.
Test Plan
--
New inline parser tests derived from the initial report and more
examples from the comments, although I think the first case should cover
them all.1 parent 6760251 commit 42cbce5
3 files changed
Lines changed: 415 additions & 4 deletions
File tree
- crates/ruff_python_parser
- resources/inline/ok
- src/parser
- tests/snapshots
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2959 | 2959 | | |
2960 | 2960 | | |
2961 | 2961 | | |
| 2962 | + | |
| 2963 | + | |
| 2964 | + | |
| 2965 | + | |
| 2966 | + | |
| 2967 | + | |
| 2968 | + | |
| 2969 | + | |
| 2970 | + | |
| 2971 | + | |
| 2972 | + | |
2962 | 2973 | | |
2963 | 2974 | | |
2964 | 2975 | | |
2965 | | - | |
2966 | | - | |
2967 | | - | |
2968 | | - | |
| 2976 | + | |
| 2977 | + | |
| 2978 | + | |
| 2979 | + | |
| 2980 | + | |
| 2981 | + | |
2969 | 2982 | | |
2970 | 2983 | | |
2971 | 2984 | | |
| |||
0 commit comments