Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion tortoise/contrib/pydantic/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import typing
from typing import Any, Callable, Dict, Optional, Type

import tortoise

if typing.TYPE_CHECKING: # pragma: nocoverage
from tortoise.models import Model

Expand All @@ -12,4 +14,9 @@ def get_annotations(cls: "Type[Model]", method: Optional[Callable] = None) -> Di
:param method: If specified, we try to get the annotations for the callable
:return: The list of annotations
"""
return typing.get_type_hints(method or cls)
localns = (
tortoise.Tortoise.apps.get(cls._meta.app, None)
if cls._meta.app
else None
)
return typing.get_type_hints(method or cls, localns=localns)
Loading