Skip to content

Add Alias provider for interface-to-implementation binding#181

Merged
lesnik512 merged 1 commit intomainfrom
173-add-alias-provider-for-interface-to-implementation-binding
May 2, 2026
Merged

Add Alias provider for interface-to-implementation binding#181
lesnik512 merged 1 commit intomainfrom
173-add-alias-provider-for-interface-to-implementation-binding

Conversation

@lesnik512
Copy link
Copy Markdown
Member

Introduces providers.Alias, a thin delegating provider that registers one type (bound_type) and resolves it through whatever provider already handles another type (source_type). Lets a Group expose both the concrete implementation and an abstract base or Protocol without registering the implementation twice or losing the concrete binding via bound_type.

resolve() looks the source provider up in providers_registry and forwards to container.resolve_provider(source), so overrides on either provider apply correctly and the source's cache (if any) is shared. get_dependencies() returns the source so cycles passing through an alias are caught by container.validate(). A missing source_type raises a new AliasSourceNotRegisteredError (ResolutionError subclass) eagerly during validation and at resolution time.

The first version is pure delegation with no independent caching; if a separately-cached alias is ever needed, a cache_settings parameter can be added later.

Closes #173

Introduces providers.Alias, a thin delegating provider that registers one
type (bound_type) and resolves it through whatever provider already handles
another type (source_type). Lets a Group expose both the concrete
implementation and an abstract base or Protocol without registering the
implementation twice or losing the concrete binding via bound_type.

resolve() looks the source provider up in providers_registry and forwards to
container.resolve_provider(source), so overrides on either provider apply
correctly and the source's cache (if any) is shared. get_dependencies()
returns the source so cycles passing through an alias are caught by
container.validate(). A missing source_type raises a new
AliasSourceNotRegisteredError (ResolutionError subclass) eagerly during
validation and at resolution time.

The first version is pure delegation with no independent caching; if a
separately-cached alias is ever needed, a cache_settings parameter can be
added later.

Closes #173

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@lesnik512 lesnik512 self-assigned this May 2, 2026
@lesnik512 lesnik512 merged commit b3c02ef into main May 2, 2026
12 of 13 checks passed
@lesnik512 lesnik512 deleted the 173-add-alias-provider-for-interface-to-implementation-binding branch May 2, 2026 15:27
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.

Add Alias provider for interface-to-implementation binding

1 participant