Skip to content

Allow AsyncFactory provider to resolve sync creators. #196

@xelandernt

Description

@xelandernt

Problem:

class MyClass: ...

class Container(BaseContainer):
    p = providers.AsyncFactory(MyClass)

await Container.p.resolve() # raises

Often, initiating MyClass might require an async dependency (in which case Factory cannot be used)

Solution:

  • Allow AsyncFactory to accept sync creators.
  • Still only allow resolution of async Factory using resolve()

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestv3Relevant to version 3.*

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions