Skip to content

Commit

Permalink
Merge pull request #278 from IvanKirpichnikov/small_changes_user_api
Browse files Browse the repository at this point in the history
Positional source for alias and optional scope for context data
  • Loading branch information
Tishka17 authored Oct 19, 2024
2 parents 6fda28a + bb87234 commit 169a4f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/dishka/dependency_source/make_alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@


def alias(
*,
source: Any,
*,
provides: Any | None = None,
cache: bool = True,
component: Component | None = None,
Expand Down
12 changes: 9 additions & 3 deletions src/dishka/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ def provide_all(

def alias(
self,
*,
source: type,
*,
provides: Any = None,
cache: bool = True,
component: Component | None = None,
Expand Down Expand Up @@ -203,9 +203,15 @@ def to_component(self, component: Component) -> ProviderWrapper:
return ProviderWrapper(component, self)

def from_context(
self, *, provides: Any, scope: BaseScope,
self,
provides: Any,
*,
scope: BaseScope | None = None,
) -> CompositeDependencySource:
composite = from_context(provides, scope=scope)
composite = from_context(
provides=provides,
scope=scope or self.scope,
)
self._add_dependency_sources(
name=str(provides),
sources=composite.dependency_sources,
Expand Down

0 comments on commit 169a4f3

Please sign in to comment.