migrate obsoleted function parse_obj_as to TypeAdapter().validate_python().

This commit is contained in:
2023-07-19 14:43:16 +09:00
parent b569c20b6e
commit 23025bd679
9 changed files with 23 additions and 23 deletions

View File

@ -1,6 +1,6 @@
from typing import Final
from pydantic import parse_obj_as
from pydantic import TypeAdapter
from pydantic.dataclasses import dataclass
from mdrsclient.api.base import BaseApi
@ -23,7 +23,7 @@ class FileApi(BaseApi):
token_check(self.connection)
response = self.connection.get(url)
self._raise_response_error(response)
return parse_obj_as(File, response.json())
return TypeAdapter(File).validate_python(response.json())
def create(self, folder_id: str, path: str) -> str:
# print(self.__class__.__name__ + "::" + sys._getframe().f_code.co_name)
@ -34,7 +34,7 @@ class FileApi(BaseApi):
with open(path, mode="rb") as fp:
response = self.connection.post(url, data=data, files={"file": fp})
self._raise_response_error(response)
ret = parse_obj_as(FileCreateResponse, response.json())
ret = TypeAdapter(FileCreateResponse).validate_python(response.json())
except OSError:
raise UnexpectedException(f"Could not open `{path}` file.")
return ret.id