Skip to content

feat: add static plugin#72

Merged
henryiii merged 1 commit into
mainfrom
feat/static-plugin
Jun 30, 2026
Merged

feat: add static plugin#72
henryiii merged 1 commit into
mainfrom
feat/static-plugin

Conversation

@henryiii

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Adds a static plugin: an alternative to writing fields in [project].

What it does

dynamic_metadata.plugins.static returns its settings verbatim as a [project] fragment. It's a thin passthrough — the loader already validates field names against ALL_FIELDS and enforces that each is listed in project.dynamic.

Two intended uses:

  • Feeding a transform pipeline — gives a later entry like substitute a dynamic value to modify, which a [project] value can't be (a scalar field may not be both static and dynamic per PEP 808).
  • Hiding metadata from tools that read [project] directly.
[project]
dynamic = ["version"]

[[tool.dynamic-metadata]]
provider = "dynamic_metadata.plugins.static"
version = "1.2.3-beta"

[[tool.dynamic-metadata]]
provider = "dynamic_metadata.plugins.substitute"
field = "version"
pattern = "-beta$"
replacement = "b0"

Design note

static is a pure passthrough rather than shape-validating values. This keeps it faithful to "an alternative to [project]" — e.g. it allows a string readme (a path), which [project] permits. No schema change needed; toml_schema.json already allows arbitrary per-entry properties.

Changes

  • src/dynamic_metadata/plugins/static.py — new plugin
  • docs/plugins.md — new static section (four → five plugins)
  • README.md — added static to the bundled-plugins list
  • tests/test_package.py — 4 new tests (multi-field set, static→substitute pipeline, unknown-field rejection, must-be-dynamic check)

All 59 tests pass; prek -a (ruff, mypy, check-sdist, …) is clean.

Adds `dynamic_metadata.plugins.static`, which returns its settings verbatim
as a `[project]` fragment — an alternative to writing fields in `[project]`.

Its main use is feeding a transform pipeline: it gives a later entry such as
`substitute` a *dynamic* value to modify, which a `[project]` value cannot be
(a scalar may not be both static and dynamic per PEP 808). It can also keep
metadata out of `[project]`, hiding it from tools that read `[project]`.

The plugin is a thin passthrough; the loader already validates field names and
that each is listed in `project.dynamic`.

Assisted-by: ClaudeCode:claude-opus-4.8
@henryiii
henryiii merged commit c77f480 into main Jun 30, 2026
11 checks passed
@henryiii
henryiii deleted the feat/static-plugin branch June 30, 2026 15:15
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