SIGN IN SIGN UP

refactor(config): add shared _resolve_component utility for plugin loading (#5215)

* add _resolve_component shared utility for plugin loading

Extracts the common pattern used by exporter factory functions:
check built-in registry → fall back to additional_properties →
load via entry point → raise if nothing matched.

The pending exporter PR (#5128) will be updated to use this utility,
reducing the three near-identical factory functions to one-liners.

Assisted-by: Claude Opus 4.6

* address review: more specific typing on _resolve_component

- Add _ComponentConfig Protocol declaring additional_properties contract
- Type registry as dict[str, Callable[[Any], Any]]
- Add Any return type annotation

Assisted-by: Claude Opus 4.6

* address review: document single-component semantic, test first-match-wins

- Add docstring note explaining the JSON schema enforces exactly one
  component per config block (minProperties: 1, maxProperties: 1), and
  that "first match wins" is the defensive fallback if validation is
  bypassed
- Add test documenting that when multiple built-in fields are set,
  the first registry match wins

Assisted-by: Claude Opus 4.6

* make _ComponentConfig.additional_properties typing more specific

Values in additional_properties are either nested config dicts (for
**kwargs splatting) or None. Document this with a more concrete type
annotation. Note: the Protocol's instance-attribute declaration still
diverges from the generated model's ClassVar; tracked separately.

Assisted-by: Claude Opus 4.6

* reference follow-up issue #5268 for ClassVar/instance-attribute mismatch

Adds a docstring note pointing to #5268 which tracks reviewing the
generated additional_properties typing for stricter type checks.

Assisted-by: Claude Opus 4.6

---------

Co-authored-by: Aaron Abbott <aaronabbott@google.com>
M
Mike Goldsmith committed
488dc4a01acdbd5e1c8b68fea72884265d9a3902
Parent: f20c680
Committed by GitHub <noreply@github.com> on 6/3/2026, 3:40:53 AM