class MediaAccept(object): def __init__(self, accept): self._type = AcceptableType(accept) def has_key(self, key): return True def get(self, item): return self._type.matches(item) def __contains__(self, item): return self._type.matches(item)
class MediaAccept(object): def __init__(self, accept: str): self._type = AcceptableType(accept) def has_key(self, key: Any) -> bool: # Literal[True]: return True def get(self, item: Any) -> Any: return self._type.matches(item) def __contains__(self, item: Any) -> Any: return self._type.matches(item) def __str__(self) -> str: return str(self._type)
def _get_return_type( accept: Optional[str], ) -> Tuple[Union[Type[CSVResponse], Type[ArrowResponse]], str]: if accept is None: accept = "*/*" type_ = AcceptableType(accept) if type_.matches("text/csv"): return CSVResponse, "text/csv" elif type_.matches("application/vnd.apache.arrow.file"): return ArrowResponse, "application/vnd.apache.arrow.file" else: raise HTTPException( status_code=406, detail= "Only 'text/csv' or 'application/vnd.apache.arrow.file' acceptable", )