Skip to content

fix(metadata): combine same-field dynamic_wheel reports with OR#1437

Merged
henryiii merged 1 commit into
mainfrom
henryiii/fix/dynamic-wheel-or
Jul 2, 2026
Merged

fix(metadata): combine same-field dynamic_wheel reports with OR#1437
henryiii merged 1 commit into
mainfrom
henryiii/fix/dynamic-wheel-or

Conversation

@henryiii

@henryiii henryiii commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

🤖 AI text below 🤖

Fixes #1436.

Problem

dynamic_wheel_fields in builder/_load_provider.py merged provider reports with dict.update, making same-field reports last-wins: a later [[tool.dynamic-metadata]] entry returning {"dependencies": False} could retract an earlier entry's {"dependencies": True}. Because contributions to a list/table field merge across entries, if any provider's part may change between the SDist and a wheel, the final value may change and PEP 643 requires it be marked Dynamic. Over-marking is allowed; under-marking is a spec violation.

A second consequence: validation ran over the merged dict after the loop, so a {"version": True} from one provider was silently masked by a later {"version": False} instead of raising.

Fix

Accumulate into a set and validate each fragment as it is collected:

  • Same-field reports combine with OR (any True wins) — a True can't be retracted.
  • The version and unknown-field checks run per-fragment, so a masked {"version": True} still raises.

Aligns with the reference implementation in scikit-build/dynamic-metadata#78.

Tests

Added test_dynamic_wheel_same_field_combines_with_or, exercising both orderings of a True/False pair. Confirmed it fails against the old last-wins code (frozenset() instead of {"dependencies"}) and passes with the fix. All existing dynamic_wheel tests still pass.

dynamic_wheel_fields merged provider reports with dict.update, so when
two [[tool.dynamic-metadata]] entries reported the same field the last
one won -- a later {"dependencies": False} could retract an earlier
{"dependencies": True}. Since a list/table field's merged value can
change if any contributing provider's part may, reports must combine
with OR (any True wins); over-marking Dynamic is allowed, under-marking
violates PEP 643. Validation now runs on each fragment as it is
collected, so a masked {"version": True} raises instead of being
silently dropped. Aligns with scikit-build/dynamic-metadata#78.

Closes #1436

Assisted-by: ClaudeCode:claude-opus-4.8
@henryiii
henryiii marked this pull request as ready for review July 2, 2026 05:13
@henryiii
henryiii merged commit 1e9a3aa into main Jul 2, 2026
66 checks passed
@henryiii
henryiii deleted the henryiii/fix/dynamic-wheel-or branch July 2, 2026 13:16
@henryiii henryiii mentioned this pull request Jul 3, 2026
5 tasks
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.

dynamic_wheel_fields: same-field reports should combine with OR, not last-wins

1 participant