Skip to content

[inherit-extend] refactor: validate inherit rules eagerly, more standard naming - #2967

Open
henryiii wants to merge 2 commits into
pypa:inherit-extendfrom
henryiii:inherit-extend-review-fixes
Open

[inherit-extend] refactor: validate inherit rules eagerly, more standard naming#2967
henryiii wants to merge 2 commits into
pypa:inherit-extendfrom
henryiii:inherit-extend-review-fixes

Conversation

@henryiii

@henryiii henryiii commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

This is based on an AI review of #2928. @joerick, I can trim out any changes you don't like. The simplification pass was based on comparisons with main, so some parts of the diff simplify the total change more than the diff in this PR itself.

  • CIBW_INHERIT_<PLATFORM> does seem to be more natural, do you like it better?

The failing CI is because the target branch needs rebasing.

🤖 AI text below 🤖

Follow-ups from a review of #2928, targeting inherit-extend.

Validation. parse_inherit now validates rule keys against the known option names (with "Perhaps you meant ...?" suggestions), requires a single token per rule, and converts shlex ValueError / non-string TOML values into OptionsReaderError. Overrides and CIBW_INHERIT are parsed eagerly in OptionsReader.__init__ again, so malformed config fails fast even on --print-build-identifiers. An append/prepend rule on a non-mergeable option (e.g. container-engine) now raises a clean error instead of a bare OptionFormat.NotSupported traceback, and an inherit rule on xbuild-tools no longer leaks the "\u0000" sentinel default into the tool list.

Interface change (worth a look). Platform-scoped env rules now use CIBW_INHERIT_<PLATFORM> (matching the CIBW_<OPTION>_<PLATFORM> convention) instead of a -<platform> suffix inside CIBW_INHERIT keys — with key validation, the suffix form would have collided with option-name checking, and CIBW_INHERIT_LINUX is what users will try first anyway. CIBW_INHERIT rules also apply to the platform variables unless a platform rule overrides them. Docs updated.

Schema. generate_schema.py derives the inherit keys from the option list instead of a hand-copied block (it was missing enable, archs, etc.), and each platform/overrides section gets an inherit table restricted to the options that section can set.

Cleanup. parse_arbitrary_key_value_string is now a thin wrapper over parse_key_value_string rather than a near-copy of it.

Regression tests were added for each fix and confirmed to fail beforehand.

One open question: the runtime also accepts the string form (inherit = "before-all: append") in TOML, but the docs and schema only describe the table form there. Left as-is; happy to restrict or document it either way.

- Validate inherit rule keys against the known option names, with
  did-you-mean suggestions; a missing colon or a typo in CIBW_INHERIT is
  now an error instead of a silent no-op.
- Require a single token per rule; convert shlex ValueError and
  non-string TOML values to OptionsReaderError instead of tracebacks.
- Parse overrides and CIBW_INHERIT eagerly in OptionsReader.__init__ so
  malformed config fails fast on every code path.
- Convert OptionFormat.NotSupported to OptionsReaderError when an
  append/prepend rule hits a non-mergeable option.
- Filter the xbuild-tools NUL sentinel out of merged lists.
- Scope platform env rules with CIBW_INHERIT_<PLATFORM> instead of a
  -<platform> suffix inside CIBW_INHERIT keys; CIBW_INHERIT rules also
  apply to CIBW_<OPTION>_<PLATFORM> unless overridden.
- Fold parse_arbitrary_key_value_string into parse_key_value_string.
- Derive the schema's inherit keys from the option list and give each
  platform/overrides section its own restricted inherit table.

Assisted-by: ClaudeCode:claude-fable-5
@henryiii henryiii changed the title Validate inherit rules eagerly and loudly [inherit-extend] refactor: validate inherit rules eagerly and loudly Aug 12, 2026
@henryiii henryiii changed the title [inherit-extend] refactor: validate inherit rules eagerly and loudly [inherit-extend] refactor: validate inherit rules eagerly, more standard naming Aug 12, 2026
Assisted-by: ClaudeCode:claude-fable-5
Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
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