feat: add from_data plugin for filling fields from TOML/JSON data files#84
Closed
henryiii wants to merge 1 commit into
Closed
feat: add from_data plugin for filling fields from TOML/JSON data files#84henryiii wants to merge 1 commit into
henryiii wants to merge 1 commit into
Conversation
Reads a value at a dotted key path from a .toml or .json file (format inferred from the extension); like ast, the value keeps its shape so list/table fields fill directly, and a table field can name one key after a dot in 'field'. Also the first bundled exemplar of the optional build_state hook: an opt-in 'states' list gates the entry to specific build states. Gated out, the entry contributes nothing and the field stays unresolved in project.dynamic; with 'states' set, dynamic_wheel marks the field Dynamic (METADATA 2.2) since it may differ between SDist and wheel builds. 'version' combined with 'states' is a hard error, as gating would leave it unresolvable in other states. Assisted-by: ClaudeCode:claude-opus-4-8
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.
🤖 AI text below 🤖
Adds a bundled
from_dataplugin that fills a field from a structured data file:pathnames a.tomlor.jsonfile (format inferred from the extension, anything else is an error) andkeyis a dotted path into the parsed document (e.g.package.versionfrom aCargo.toml). Likeast, the value keeps its shape, so list/table fields fill directly; a table field can instead name one key after a dot infield(optional-dependencies.test), followingfrom_file. Key segments containing a literal dot are not addressable (documented limitation), and a missing segment errors naming the failing segment.This is also the first bundled exemplar of the optional
build_statehook (a class provider stashing the state onself). The opt-instatessetting is a flat list of build states validated againstBUILD_STATES:statesabsent: unconditional, identical to today — no behavior change.states:dynamic_metadatareturns{}; the field stays inproject.dynamicunresolved unless another entry provides it (the docs say to pair a gated entry with one covering the other states).statesset,dynamic_wheel(stateless, per the loader contract) reports the field Dynamic for METADATA 2.2, since a gated field can differ between the SDist and wheel builds; withoutstatesnothing is dynamic.field = "version"+statesis a hard error — gating the version would leave it unresolvable in other states, and version may never be Dynamic.The JSON schema needed no change: per-plugin settings are not modeled there (entries are
additionalProperties: true).