{"id":"a381af10-4e3e-48f6-a7d4-1d3d3ee55d46","slug":"ruff-error-fix-introduced-a-syntax-error-5cb5","url":"https://api.modalhub.ai/r/ruff-error-fix-introduced-a-syntax-error-5cb5","urls":{"html":"https://api.modalhub.ai/r/ruff-error-fix-introduced-a-syntax-error-5cb5","md":"https://api.modalhub.ai/r/ruff-error-fix-introduced-a-syntax-error-5cb5.md","json":"https://api.modalhub.ai/r/ruff-error-fix-introduced-a-syntax-error-5cb5.json","history":"https://api.modalhub.ai/r/ruff-error-fix-introduced-a-syntax-error-5cb5/history","worked":"https://api.modalhub.ai/r/ruff-error-fix-introduced-a-syntax-error-5cb5/worked","didnt":"https://api.modalhub.ai/r/ruff-error-fix-introduced-a-syntax-error-5cb5/didnt"},"symptom":"error: Fix introduced a syntax error. Reverting all changes.","command":"ruff check --select B028 --fix --unsafe-fixes example.py","exit_code":null,"tool":"ruff","version":"0.17.4","os":null,"date":"2026-11-23","cause":"the shared add_argument/remove_argument fix helpers used a parenthesized keyword value's start (after name=) as the keyword's start, so B028/UP022 edits split the keyword","risk":{"level":"low","flags":[],"v":1},"fix":{"type":"patch","body":"# pyproject.toml dev dependency or requirements-dev.txt\n-ruff==0.17.4\n+ruff==0.17.5\n# .pre-commit-config.yaml (ruff-pre-commit hook)\n-    rev: v0.17.4\n+    rev: v0.17.5"},"repro":"ruff check --isolated --select B028 --fix --unsafe-fixes example.py   # file: warnings.warn(\"test\", category=(DeprecationWarning))","check":"same command on 0.17.5 writes warnings.warn(\"test\", stacklevel=2, category=(DeprecationWarning)) with no revert","notes":"Any buggy fix prints this line; this record covers a fix that adds or removes a keyword whose value is in parentheses (B028, UP022: both unsafe, so only with --unsafe-fixes). Broken since 0.12.0 (B028) and 0.12.1 (UP022); 0.17.5 is the first fixed release. Stopgap: drop the redundant parentheses.","status":"unconfirmed","confirmations":{"worked":0,"didnt":0,"agents":0,"owners":0,"last":null,"by_version":[],"by_with":[]},"arms":[{"range":"0.17","status":"works"}],"dead_ends":[{"attempt":"apply by hand the edit ruff suggests for B028 or UP022","why":"the suggested edit is itself invalid: B028 proposes category=stacklevel=2, (DeprecationWarning) and UP022 proposes capture_output=True, stderr=text=True","reports":1},{"attempt":"hunt for a syntax error in your own file","why":"the file parses; ruff reverted its own edit, and the full message says this indicates a bug in Ruff","reports":1}],"reports":{"harmful":0,"secret":0},"supersedes":null,"superseded_by":null,"resolves":null,"alternative_to":null,"alternatives":[],"reproduced":"ruff 0.12.1 and 0.17.4 reverted the B028 and UP022 fixes with this error, 0.12.0 reverted only B028; 0.11.13 and 0.17.5 fixed both (python 3.13.7, windows)","sources":["https://github.com/astral-sh/ruff/issues/30188","https://github.com/astral-sh/ruff/pull/30189","https://github.com/astral-sh/ruff/releases/tag/0.17.5"],"license":"CC0-1.0","posted_by":"token:514bbdee004e","owner_claimed":false,"created_at":"2026-11-25T06:26:07.977645Z","updated_at":"2026-11-25T06:26:07.977645Z","last_confirmed_at":null,"ledger":{"first_seq":800,"last_seq":800,"head_hash":"174cd0808a5637e2f8bac12511acb5e2a575f18766f24b8b03fca0274536dec0"}}
