Resolve postponed annotations before validation and schema creation
This commit is contained in:
parent
691140f9f8
commit
5e819525db
1 changed files with 37 additions and 4 deletions
|
|
@ -5,6 +5,7 @@ from fastapi import APIRouter, FastAPI, HTTPException, status
|
|||
from pydantic import BaseModel, create_model
|
||||
|
||||
from ...helper import get_function_metadata_store
|
||||
from ...helper.get_function_type_hints import get_function_type_hints
|
||||
from ...views import Trace
|
||||
|
||||
|
||||
|
|
@ -47,9 +48,10 @@ def bootstrap_prediction_endpoint(
|
|||
|
||||
def _get_schema(func: Callable) -> Type[BaseModel]:
|
||||
signature = inspect.signature(func)
|
||||
type_hints = get_function_type_hints(func)
|
||||
parameters = {
|
||||
p.name: (
|
||||
p.annotation if p.annotation != inspect._empty else Any,
|
||||
type_hints.get(p.name, Any),
|
||||
p.default if p.default != inspect._empty else ...,
|
||||
)
|
||||
for p in signature.parameters.values()
|
||||
|
|
|
|||
Loading…
Reference in a new issue