Skip to content

Close the remaining PEP 701 gaps in the Python floor check - #712

Merged
earthtojake merged 1 commit into
mainfrom
claude/floor-check-pep701-followup
Oct 28, 2026
Merged

earthtojake merged 1 commit into
mainfrom
claude/floor-check-pep701-followup

Conversation

@earthtojake

Copy link
Copy Markdown
Owner

Follow-up to #708. That PR caught f-strings that nest their own quote, a pattern Python 3.11 rejects but that ast.parse(feature_version=(3, 11)) on 3.12+ accepts. Review found three more PEP 701 forms that slip past the floor check the same way, plus a few nits. This closes them in the same token walk, with no CI changes.

What the check now flags (only when requires-python is below 3.12)

Each case below was checked against a real CPython 3.11 compile():

  • A field reuses its f-string's quote (Catch same-quote nested f-strings in the 3.11 floor check #708's rule): f"{d["k"]}"
  • A backslash in a field's expression: f"{'\n'.join(a)}", which 3.11 rejects with "expression part cannot include a backslash". A backslash in the literal text or the format spec is still allowed.
  • A comment in a field: f"""{a # why\n}""". 3.11 rejects this even inside a triple-quoted f-string.
  • A line break in a field of a single-quoted f-string: f"{a +\n b}". A triple-quoted f-string may still break lines in its fields.
  • Fields nested more than two deep: f"{a:{b:{c}}}", which 3.11 rejects as "nested too deeply".

Nits from the #708 review

  • One line with several offending strings is reported once.
  • The module docstring no longer says feature_version answers "would the floor accept this file?" for f-strings.
  • _quote no longer strips the t/T prefixes of t-strings, which it never tracks.

Other 3.12+ syntax is already rejected by feature_version=(3, 11). That covers PEP 695 type parameters and type aliases, and 3.14's t-strings.

Testing

  • A 54-case harness compared the real 3.11 verdict with (feature_version or this check) on 3.12 and 3.13, with 0 mismatches. A separate set of 22 cases, written independently, also gave 0 mismatches on both.
  • For each new rule, adding its offending line to a cadgen module made the floor test fail and name the file and line. The test passes on today's main.
  • scripts/test/test-global.sh: 224 tests, OK (1 skipped). On 3.11 the pinning test skips, because the interpreter rejects all of this syntax itself.

🤖 Generated with Claude Code

ast.parse(feature_version=(3, 11)) on 3.12+ accepts every PEP 701 f-string, not
just a nested same quote. Below a 3.12 floor the token walk now also flags a
backslash or a comment in a field, a line break in a field of a single-quoted
f-string, and fields nested more than two deep. Each was checked against a
real 3.11. Offenders report each line once, and the docstring says where
feature_version stops answering the question.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@earthtojake
earthtojake merged commit 679f434 into main Oct 28, 2026
11 checks passed
@earthtojake
earthtojake deleted the claude/floor-check-pep701-followup branch October 28, 2026 17:40
earthtojake added a commit that referenced this pull request Oct 28, 2026
Releases 0.8.2: VERSION, the derived metadata and every cadgen pin.

Ships #706: Windows snapshots hand their picture over through a file when
OCP refuses a stream (#709, the fallback BruceWu1126 proposed and tested
in #710), mesh-file snapshots through a worker, local crash diagnostics,
the viewer's pointer-lift guard and a readable error when Windows refuses
the kernel processes. Also #708 and #712 (the Python floor check).

Co-authored-by: BruceWu1126 <196750230+BruceWu1126@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant