-
-
Notifications
You must be signed in to change notification settings - Fork 337
-
Right now, it is required to define each dependency manually:
class Container(containers.DeclarativeContainer): database = providers.Singleton(sqlite3.connect, ":memory:") user_service = providers.Factory( UserService, db=database, ) auth_service = providers.Factory( AuthService, db=database, user_service=user_service, )
It would be much easier and helpful, if it could automatically guess the types of the data and build the dependency tree based on it:
class Container(containers.DeclarativeContainer): database = providers.Singleton(sqlite3.connect, ":memory:") user_service = providers.Factory(UserService) auth_service = providers.Factory(AuthService) class UserService: def __init__(self, db: sqlite3.Connection): self.db = db class AuthService: def __init__(self, db: sqlite3.Connection, user_service: UserService): self.db = db self.user_service = user_service
What do you think?
Beta Was this translation helpful? Give feedback.
All reactions
-
🚀 1
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment