def _load(cls: Type[T], res: Response) -> T: if cls == Any: return res.json() else: if typing_inspect.get_origin(cls) == list: cls, = typing_inspect.get_args(cls) many = True else: many = False schema = get_schema(cls, many=many) obj = schema.load(res.json()) return cast(T, obj)
def exception_from_response(response: requests.Response) -> MosregException: n_json = None try: n_json = response.json() except ValueError: pass return MosregException(n_json, response.text, response.status_code)