@@ -370,7 +370,7 @@ def _fetch_access_token(self, session: Session, credential: str) -> str:
370
370
except HTTPError as exc :
371
371
self ._handle_non_200_response (exc , {400 : OAuthError , 401 : OAuthError })
372
372
373
- return TokenResponse ( ** response .json () ).access_token
373
+ return TokenResponse . model_validate_json ( response .text ).access_token
374
374
375
375
def _fetch_config (self ) -> None :
376
376
params = {}
@@ -383,7 +383,7 @@ def _fetch_config(self) -> None:
383
383
response .raise_for_status ()
384
384
except HTTPError as exc :
385
385
self ._handle_non_200_response (exc , {})
386
- config_response = ConfigResponse ( ** response .json () )
386
+ config_response = ConfigResponse . model_validate_json ( response .text )
387
387
388
388
config = config_response .defaults
389
389
config .update (self .properties )
@@ -443,14 +443,14 @@ def _handle_non_200_response(self, exc: HTTPError, error_handler: Dict[int, Type
443
443
try :
444
444
if exception == OAuthError :
445
445
# The OAuthErrorResponse has a different format
446
- error = OAuthErrorResponse ( ** exc .response .json () )
446
+ error = OAuthErrorResponse . model_validate_json ( exc .response .text )
447
447
response = str (error .error )
448
448
if description := error .error_description :
449
449
response += f": { description } "
450
450
if uri := error .error_uri :
451
451
response += f" ({ uri } )"
452
452
else :
453
- error = ErrorResponse ( ** exc .response .json () ).error
453
+ error = ErrorResponse . model_validate_json ( exc .response .text ).error
454
454
response = f"{ error .type } : { error .message } "
455
455
except JSONDecodeError :
456
456
# In the case we don't have a proper response
@@ -588,7 +588,7 @@ def _create_table(
588
588
response .raise_for_status ()
589
589
except HTTPError as exc :
590
590
self ._handle_non_200_response (exc , {409 : TableAlreadyExistsError })
591
- return TableResponse ( ** response .json () )
591
+ return TableResponse . model_validate_json ( response .text )
592
592
593
593
@retry (** _RETRY_ARGS )
594
594
def create_table (
@@ -662,7 +662,7 @@ def register_table(self, identifier: Union[str, Identifier], metadata_location:
662
662
except HTTPError as exc :
663
663
self ._handle_non_200_response (exc , {409 : TableAlreadyExistsError })
664
664
665
- table_response = TableResponse ( ** response .json () )
665
+ table_response = TableResponse . model_validate_json ( response .text )
666
666
return self ._response_to_table (self .identifier_to_tuple (identifier ), table_response )
667
667
668
668
@retry (** _RETRY_ARGS )
@@ -674,7 +674,7 @@ def list_tables(self, namespace: Union[str, Identifier]) -> List[Identifier]:
674
674
response .raise_for_status ()
675
675
except HTTPError as exc :
676
676
self ._handle_non_200_response (exc , {404 : NoSuchNamespaceError })
677
- return [(* table .namespace , table .name ) for table in ListTablesResponse ( ** response .json () ).identifiers ]
677
+ return [(* table .namespace , table .name ) for table in ListTablesResponse . model_validate_json ( response .text ).identifiers ]
678
678
679
679
@retry (** _RETRY_ARGS )
680
680
def load_table (self , identifier : Union [str , Identifier ]) -> Table :
@@ -684,7 +684,7 @@ def load_table(self, identifier: Union[str, Identifier]) -> Table:
684
684
except HTTPError as exc :
685
685
self ._handle_non_200_response (exc , {404 : NoSuchTableError })
686
686
687
- table_response = TableResponse ( ** response .json () )
687
+ table_response = TableResponse . model_validate_json ( response .text )
688
688
return self ._response_to_table (self .identifier_to_tuple (identifier ), table_response )
689
689
690
690
@retry (** _RETRY_ARGS )
@@ -735,7 +735,7 @@ def list_views(self, namespace: Union[str, Identifier]) -> List[Identifier]:
735
735
response .raise_for_status ()
736
736
except HTTPError as exc :
737
737
self ._handle_non_200_response (exc , {404 : NoSuchNamespaceError })
738
- return [(* view .namespace , view .name ) for view in ListViewsResponse ( ** response .json () ).identifiers ]
738
+ return [(* view .namespace , view .name ) for view in ListViewsResponse . model_validate_json ( response .text ).identifiers ]
739
739
740
740
@retry (** _RETRY_ARGS )
741
741
def commit_table (
@@ -781,7 +781,7 @@ def commit_table(
781
781
504 : CommitStateUnknownException ,
782
782
},
783
783
)
784
- return CommitTableResponse ( ** response .json () )
784
+ return CommitTableResponse . model_validate_json ( response .text )
785
785
786
786
@retry (** _RETRY_ARGS )
787
787
def create_namespace (self , namespace : Union [str , Identifier ], properties : Properties = EMPTY_DICT ) -> None :
@@ -818,7 +818,7 @@ def list_namespaces(self, namespace: Union[str, Identifier] = ()) -> List[Identi
818
818
except HTTPError as exc :
819
819
self ._handle_non_200_response (exc , {})
820
820
821
- return ListNamespaceResponse ( ** response .json () ).namespaces
821
+ return ListNamespaceResponse . model_validate_json ( response .text ).namespaces
822
822
823
823
@retry (** _RETRY_ARGS )
824
824
def load_namespace_properties (self , namespace : Union [str , Identifier ]) -> Properties :
@@ -830,7 +830,7 @@ def load_namespace_properties(self, namespace: Union[str, Identifier]) -> Proper
830
830
except HTTPError as exc :
831
831
self ._handle_non_200_response (exc , {404 : NoSuchNamespaceError })
832
832
833
- return NamespaceResponse ( ** response .json () ).properties
833
+ return NamespaceResponse . model_validate_json ( response .text ).properties
834
834
835
835
@retry (** _RETRY_ARGS )
836
836
def update_namespace_properties (
@@ -844,7 +844,7 @@ def update_namespace_properties(
844
844
response .raise_for_status ()
845
845
except HTTPError as exc :
846
846
self ._handle_non_200_response (exc , {404 : NoSuchNamespaceError })
847
- parsed_response = UpdateNamespacePropertiesResponse ( ** response .json () )
847
+ parsed_response = UpdateNamespacePropertiesResponse . model_validate_json ( response .text )
848
848
return PropertiesUpdateSummary (
849
849
removed = parsed_response .removed ,
850
850
updated = parsed_response .updated ,
0 commit comments