feat: type the bindings input with a single-source-of-truth enum#3273
Merged
Conversation
Replace the raw `Option<String>` bindings input on the CLI (`--bindings`), `maturin develop`, and `[tool.maturin] bindings` with a dedicated `Bindings` enum (pyo3, pyo3-ffi, cffi, uniffi, bin). Every accepted spelling lives in one place (`Bindings::as_str`); `FromStr`, `Display`, serde, clap `ValueEnum` and schemars all delegate to it, so the accepted spellings can never drift apart. `find_bridge`/`find_bridge_with_deps` now take `Option<Bindings>` and convert to `BridgeModel` at the point the string used to be consumed. `BridgeModel` is deliberately not reused as the input type: auto-detection and resolved PyO3 metadata are semantic states, not input spellings. Behavior is backward compatible: the serialized values and CLI possible-values diagnostic are byte-identical to before, and TOML now rejects unknown values with serde's variant-naming error instead of the old downstream "unknown binding type". Auto-detection (bindings omitted) is unchanged. Regenerated maturin.schema.json: ToolMaturin.bindings becomes a `$ref` to a new `Bindings` string-enum def, documented in the house style (a `oneOf` of per-variant `const` values, each with a one-line description).
messense
force-pushed
the
refactor/a4-typed-bindings
branch
from
July 22, 2026 10:56
563fbff to
7d6cabc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace the raw
Option<String>bindings input on the CLI (--bindings),maturin develop, and[tool.maturin] bindingswith a dedicatedBindingsenum (pyo3, pyo3-ffi, cffi, uniffi, bin). Every accepted spelling lives in one place (Bindings::as_str);FromStr,Display, serde, clapValueEnumand schemars all delegate to it, so the accepted spellings can never drift apart.find_bridge/find_bridge_with_depsnow takeOption<Bindings>and convert toBridgeModelat the point the string used to be consumed.BridgeModelis deliberately not reused as the input type: auto-detection and resolved PyO3 metadata are semantic states, not input spellings.Behavior is backward compatible: the serialized values and CLI possible-values diagnostic are byte-identical to before, and TOML now rejects unknown values with serde's variant-naming error instead of the old downstream "unknown binding type". Auto-detection (bindings omitted) is unchanged.
Regenerated maturin.schema.json: ToolMaturin.bindings becomes a
$refto a newBindingsstring-enum def, documented in the house style (aoneOfof per-variantconstvalues, each with a one-line description).