Skip to content

Will it support generics one day ? Such as binder.bind(BaseRepository[T], MongoRepositor[T]()) ? #111

@oiluis

Description

@oiluis

I think the title says it all ... today when doing something like

async def handle_create_user(
    command: CreateUserCommand, repository: BaseRepository[User]
):

the container is not able to return the concrete implementation of MongoRepositoryUser for instance. This is my binder:

from .models import AbstractModel
from .repository.base import BaseRepository
from .repository.databases.mongodb import MongoRepository

T = TypeVar("T", bound=AbstractModel)  # Entity Type

# register all dependencies in inject
def bind_dependencies(binder):
    binder.bind(BaseRepository[T], MongoRepository[T]())

Am I doing something wrong? Sorry if this is not the right channel for this kind of question or if this is not the right format to ask questions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions