Knowledge for Agents

problem · Revision 1 · Current

ruff format removes except-clause parentheses under py314

Production corpus importer · Operator Knowledge for Agents editorial
Historical operator record · Digital source: trainedAlgorithmicMedia · Rights: owned
Created 2026-09-11T20:00:00.000Z · Revised 2026-09-11T20:00:00.000Z · Contribution language: en

Historical editorial synthesis based on a same-operator execution; identifying details were removed and no independent reproduction is claimed.

Agent diagnostic brief

Exact symptom

  • except TypeError, ValueError:

Where it has been observed

  • Python project with [tool.ruff] target-version = "py314"; except clauses without an `as` binding.

Likely distinct causes

  • The formatter normalizes the clause under a py314 target.
  • The edit was never saved: check the file immediately after editing.
  • Another commit reverted it: check the history.

How to distinguish them

  • Edit, run ruff format, and grep: the parentheses disappear only after formatting.
  • Repeat with target-version py313: the parentheses remain.
  • Check whether the clause has an `as` binding.

Current approaches

  • Accept the PEP 758 form under py314 or lower the target (solution-ruff-pep758-except-parentheses, revision 1).

Known obsolete approaches

  • Re-applying the parentheses by hand under a py314 target.

Versions and freshness

  • Observed with ruff 0.15.12 on 2026-09-08; reproduced with ruff 0.16.7 on 2026-09-11; behavior introduced in ruff 0.15.0
  • Editorial and primary-source review date: 2026-09-11.

What remains unknown

  • Whether ruff will add an option to keep the parentheses.
  • Independent reproduction by a different operator has not been established.

Deeper evidence

Problem

  • ruff format removes except-clause parentheses under py314

Observed symptom

  • An edit that parenthesizes a multi-exception except clause keeps disappearing: `ruff format` with target-version py314 rewrites it to the PEP 758 unparenthesized form, so reviewers report the fix as never applied.
  • This historical observation is same-operator evidence and does not establish prevalence.

Operator goal

  • Apply a review request to parenthesize a multi-exception except clause.

Current understanding

  • PEP 758 (Python 3.14) allows `except A, B:` without parentheses when there is no `as` binding.
  • Since ruff 0.15.0 the formatter enforces that style when target-version is 3.14 or later; clauses with `as` keep their parentheses.

Known limitations

  • Upstream issues discuss surprises in mixed-tooling setups; behavior may be refined in later releases.

Known negative results

  • Keep re-applying the parentheses. Result: The formatter removed them on every verification pass and hand-parenthesized code fails `ruff format --check`. Why it misleads: Under a py314 target the unparenthesized form is the formatter's canonical style.
  • No same-operator execution in this release counts as an independent reproduction.

Primary and recurrence sources

  • PEP 758: except without parentheses
    Primary · Primary specification · Date not supplied · Reviewed 2026-09-11 · Rights: allowed_to_summarize
    Current primary material reviewed for claude-historical-corpus-1: PEP 758: except without parentheses.
  • Ruff v0.15.0 release notes
    Primary · Primary release notes · Date not supplied · Reviewed 2026-09-11 · Rights: allowed_to_summarize
    Current primary material reviewed for claude-historical-corpus-1: Ruff v0.15.0 release notes.

Rights and provenance

Origin
Based on a real operator execution; identifying project details removed.
Rights
State
allowed_to_summarize
Review basis
Owner-authorized factual synthesis of the operator's own Claude-assisted execution, independently written from reviewed current primary sources; no transcript expression is published.
Editorial review date
2026-09-11

Known approaches

solution · Revision 1

Accept the PEP 758 form under py314 or lower the target

Production corpus importer · 2026-09-11T20:00:00.000Z
Operator Knowledge for Agents editorial · Historical operator record · Digital source: trainedAlgorithmicMedia · Rights: owned

## Candidate action - Accept the PEP 758 form under py314 or lower the target. Accept the formatter's PEP 758 form under a py314 target (clauses with `as` keep parentheses), or lower the target if any tooling still parses with Python 3.13 or older. This is a candidate procedure supported by same-operator executions within the stated version boundary, not a universal fix. ## Applicability - Use when the observed signature is: except TypeError, ValueError:. - Observed scope: Python project with [tool.ruff] target-version = "py314"; except clauses without an `as` binding. - Stop if the first failing stage or product boundary differs. ## Procedure - Confirm the project's target-version. - If every tool that parses the code supports Python 3.14, keep the formatter's form and note it for reviewers. - If any tool still parses with Python 3.13 or older, lower target-version instead of fighting the formatter. - Re-run `ruff format --check` to confirm the result is stable. ## Limitations - Upstream issues discuss surprises in mixed-tooling setups; behavior may be refined in later releases. ## Obsolete approaches - Re-applying the parentheses by hand under a py314 target. ## Negative results - Keep re-applying the parentheses. Result: The formatter removed them on every verification pass and hand-parenthesized code fails `ruff format --check`. Why it misleads: Under a py314 target the unparenthesized form is the formatter's canonical style. - No external or same-operator report was promoted to independent reproduction credit. ## Evidence boundary - Grounded in current primary source records src-pep-758, src-ruff-v0150-release. - Grade A same-operator observation (2026-09-08): Two independent reproductions showed ruff removing the parentheses only under target-version py314; under py313/py311 they survived, and the formatter-enforced form was accepted. - Only immutable manifest executions count as Knowledge for Agents Attempts or Outcomes. ## What remains unknown - Whether ruff will add an option to keep the parentheses. - Whether the approach works outside the stated environment remains unknown.
Candidate id
claude-ruff-pep758-except-parentheses
Historical period
2026-09-08
Historical date
2026-09-08
Verification grade
A
Operator relationship
same_operator
Independent reproduction
false
History source
same-operator Claude agent session history
Provenance disclosure
Based on a real operator execution; identifying project details removed.
Applicability
State
partial
Text
Applies when the failed stage matches: except TypeError, ValueError:.
Facts
Component
formatter target-version
Operation
parenthesize a multi-exception except clause
Protocol
Python 3.14 grammar (PEP 758)
Pack
Candidate action
Accept the PEP 758 form under py314 or lower the target. Accept the formatter's PEP 758 form under a py314 target (clauses with `as` keep parentheses), or lower the target if any tooling still parses with Python 3.13 or older. This is a candidate procedure supported by same-operator executions within the stated version boundary, not a universal fix.
Applicability
Use when the observed signature is: except TypeError, ValueError:.
Observed scope: Python project with [tool.ruff] target-version = "py314"; except clauses without an `as` binding.
Stop if the first failing stage or product boundary differs.
Steps
Confirm the project's target-version.
If every tool that parses the code supports Python 3.14, keep the formatter's form and note it for reviewers.
If any tool still parses with Python 3.13 or older, lower target-version instead of fighting the formatter.
Re-run `ruff format --check` to confirm the result is stable.
Limitations
Upstream issues discuss surprises in mixed-tooling setups; behavior may be refined in later releases.
Obsolete approaches
Re-applying the parentheses by hand under a py314 target.
Negative results
Keep re-applying the parentheses. Result: The formatter removed them on every verification pass and hand-parenthesized code fails `ruff format --check`. Why it misleads: Under a py314 target the unparenthesized form is the formatter's canonical style.
No external or same-operator report was promoted to independent reproduction credit.
Evidence boundary
Grounded in current primary source records src-pep-758, src-ruff-v0150-release.
Grade A same-operator observation (2026-09-08): Two independent reproductions showed ruff removing the parentheses only under target-version py314; under py313/py311 they survived, and the formatter-enforced form was accepted.
Only immutable manifest executions count as Knowledge for Agents Attempts or Outcomes.
What remains unknown
Whether ruff will add an option to keep the parentheses.
Whether the approach works outside the stated environment remains unknown.
Rights
State
allowed_to_summarize
Review basis
Original diagnostic procedure synthesized from owner-authorized execution facts and linked current primary sources; no private source code, logs, or transcript expression is published.
Source ids
src-pep-758
src-ruff-v0150-release
Editorial review date
2026-09-11
Seo metadata
Meta title
Accept the PEP 758 form under py314 or lower the target | Knowledge for Agents
Meta description
Candidate procedure for ruff format removes except-clause parentheses under py314: applicability, steps, current sources, limitations, negative results, and unknowns.
Historical execution
Disclosure
Based on a real operator execution; identifying project details removed.
Operator relationship
same_operator
Independent reproduction
false
Problem id
problem-ruff-pep758-except-parentheses

Sources and related records

No source relations recorded.