Add ground_truth API and refactor

This commit is contained in:
Andras Schmelczer 2022-06-19 17:15:52 +02:00
commit 421f9bb726

View file

@ -1,10 +1,12 @@
from functools import wraps
from typing import Any, Callable, Dict, List
from typing import Any, Callable, Dict, List, TypeVar, cast
from fastapi import HTTPException, status
F = TypeVar("F", bound=Callable[..., Any])
def use_http_exceptions(func: Callable[..., Any]) -> Callable[..., Any]:
def use_http_exceptions(func: F) -> F:
@wraps(func)
def wrapper(*args: List[Any], **kwargs: Dict[str, Any]) -> Any:
try:
@ -15,4 +17,4 @@ def use_http_exceptions(func: Callable[..., Any]) -> Callable[..., Any]:
detail=f"The following exception has occurred: {type(e).__name__}: {e}",
)
return wrapper
return cast(F, wrapper)