mirror of
https://github.com/astral-sh/ruff.git
synced 2026-11-23 01:50:49 +08:00
Summary -- While reviewing #28231, Codex found a preexisting bug shared with our unary minus handling. Namely, CPython emits an error for code like this, where the unary expression is part of a longer expression: ```pycon >>> match foo: ... case -1**2: ... ... File "<python-input-0>", line 2 case -1**2: ... ^^ SyntaxError: invalid syntax ``` but Ruff does not: ```console $ ruff check --ignore ALL - <<EOF match foo: case -1**2: ... EOF All checks passed! ``` We now verify that the parsed unary expression is a number literal and emit an error if not. Test Plan -- New inline snapshots