Add ground_truth API and refactor
This commit is contained in:
parent
c5cafbee47
commit
421f9bb726
1 changed files with 409 additions and 211 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue