Skip to content
Discussion options

You must be logged in to vote

@michaelschmit Your code definitely can be changed to work this way:

from typing import Any, Type

from fastapi import APIRouter, Depends, FastAPI
from starlette.testclient import TestClient


# Declare the access types and dependencies
class DataAccessClass1:
    pass


class DataAccessClass2:
    pass


class DataAccessConfig:
    def __init__(self, access_1: Type[Any], access_2: Type[Any]) -> None:
        self.access_1 = access_1
        self.access_2 = access_2


class AccessFactory:
    def __init__(self, access_types: DataAccessConfig) -> None:
        self._data_access_1 = access_types.access_1
        self._data_access_2 = access_types.access_2

    async def get_status(self) -> str

Replies: 14 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by YuriiMotov
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem question-migrate
4 participants
Converted from issue

This discussion was converted from issue #656 on February 28, 2023 11:32.