-
-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
I'm running into an issue when returning a class as a return type.
Omitting the return type works great:
from ..config import Config
def get_config():
return Config()Specifying an explicit return type works great:
from ..config import Config
def get_config() -> Config:
return Config()Specifying the type under TYPE_CHECKING fails:
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from ..config import Config
def get_config() -> "Config":
from ..config import Config
return Config()It fails with this error:
self = <fast_depends.core.model.CallModel object at 0x1045a8300>
value = Config(...)
def _cast_response(self, /, value: Any) -> Any:
if self.response_model is not None:
> return self.response_model(response=value).response
E pydantic.errors.PydanticUserError: `ResponseModel` is not fully defined; you should define `Config`, then call `ResponseModel.model_rebuild()`.
E
E For further information visit https://errors.pydantic.dev/2.10/u/class-not-fully-defined
.venv/lib/python3.12/site-packages/fast_depends/core/model.py:325: PydanticUserError
Is this use case supported?
For my application, config.py does some heavy lifting that I'm trying to mock in my tests, therefore I'm trying to avoid loading it unless the file is explicitly called, but I want to reference the type.
Metadata
Metadata
Assignees
Labels
No labels