Skip to content

Commit

Permalink
fix passing type
Browse files Browse the repository at this point in the history
  • Loading branch information
Tishka17 committed Oct 4, 2024
1 parent 2fbb7e8 commit 0dbbf44
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions src/dishka/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@
from .provider import BaseProvider


class UndecoratedType:
"""Container for a type which is decorated in other place."""
def __init__(self, original: type[Any], depth: int) -> None:
self.original = original
self.level = depth

def __repr__(self) -> str:
return f"UndecoratedType({self.original}, depth={self.level})"


class Registry:
__slots__ = ("scope", "factories", "compiled", "compiled_async")

Expand All @@ -49,8 +39,13 @@ def __init__(self, scope: BaseScope):
self.compiled: dict[DependencyKey, Callable[..., Any]] = {}
self.compiled_async: dict[DependencyKey, Callable[..., Any]] = {}

def add_factory(self, factory: Factory) -> None:
provides = factory.provides
def add_factory(
self,
factory: Factory,
provides: DependencyKey| None = None,
) -> None:
if provides is None:
provides = factory.provides
self.factories[provides] = factory

def get_compiled(
Expand Down Expand Up @@ -508,6 +503,4 @@ def _post_process_generic_factories(self):
for registry, factory in found:
origin = get_origin(factory.provides.type_hint)
origin_key = DependencyKey(origin, factory.provides.component)
factory = copy(factory)
factory.provides = origin_key
registry.add_factory(factory)
registry.add_factory(factory, origin_key)

0 comments on commit 0dbbf44

Please sign in to comment.