1414# KIND, either express or implied. See the License for the
1515# specific language governing permissions and limitations
1616# under the License.
17+ from __future__ import annotations
18+
1719from collections import deque
1820from enum import Enum
1921from typing import (
2022 TYPE_CHECKING ,
2123 Any ,
22- Union ,
2324)
2425from urllib .parse import quote , unquote
2526
@@ -117,7 +118,7 @@ def __str__(self) -> str:
117118 return f"{ self .http_method .value } { self .path } "
118119
119120 @classmethod
120- def from_string (cls , endpoint : str ) -> " Endpoint" :
121+ def from_string (cls , endpoint : str ) -> Endpoint :
121122 elements = endpoint .strip ().split (None , 1 )
122123 if len (elements ) != 2 :
123124 raise ValueError (f"Invalid endpoint (must consist of two elements separated by a single space): { endpoint } " )
@@ -268,7 +269,7 @@ class TableResponse(IcebergBaseModel):
268269
269270
270271class ViewResponse (IcebergBaseModel ):
271- metadata_location : Optional [ str ] = Field (alias = "metadata-location" , default = None )
272+ metadata_location : str | None = Field (alias = "metadata-location" , default = None )
272273 metadata : ViewMetadata
273274 config : Properties = Field (default_factory = dict )
274275
@@ -290,13 +291,13 @@ def transform_properties_dict_value_to_str(cls, properties: Properties) -> dict[
290291
291292class CreateViewRequest (IcebergBaseModel ):
292293 name : str = Field ()
293- location : Optional [ str ] = Field ()
294+ location : str | None = Field ()
294295 view_schema : Schema = Field (alias = "schema" )
295296 view_version : ViewVersion = Field (alias = "view-version" )
296297 properties : Properties = Field (default_factory = dict )
297298
298299 @field_validator ("properties" , mode = "before" )
299- def transform_properties_dict_value_to_str (cls , properties : Properties ) -> Dict [str , str ]:
300+ def transform_properties_dict_value_to_str (cls , properties : Properties ) -> dict [str , str ]:
300301 return transform_dict_value_to_str (properties )
301302
302303
@@ -778,7 +779,7 @@ def _response_to_staged_table(self, identifier_tuple: tuple[str, ...], table_res
778779 catalog = self ,
779780 )
780781
781- def _response_to_view (self , identifier_tuple : Tuple [str , ...], view_response : ViewResponse ) -> View :
782+ def _response_to_view (self , identifier_tuple : tuple [str , ...], view_response : ViewResponse ) -> View :
782783 return View (
783784 identifier = identifier_tuple ,
784785 metadata = view_response .metadata ,
@@ -803,7 +804,7 @@ def _config_headers(self, session: Session) -> None:
803804 def _create_table (
804805 self ,
805806 identifier : str | Identifier ,
806- schema : Union [ Schema , " pa.Schema" ] ,
807+ schema : Schema | pa .Schema ,
807808 location : str | None = None ,
808809 partition_spec : PartitionSpec = UNPARTITIONED_PARTITION_SPEC ,
809810 sort_order : SortOrder = UNSORTED_SORT_ORDER ,
@@ -846,7 +847,7 @@ def _create_table(
846847 def create_table (
847848 self ,
848849 identifier : str | Identifier ,
849- schema : Union [ Schema , " pa.Schema" ] ,
850+ schema : Schema | pa .Schema ,
850851 location : str | None = None ,
851852 partition_spec : PartitionSpec = UNPARTITIONED_PARTITION_SPEC ,
852853 sort_order : SortOrder = UNSORTED_SORT_ORDER ,
@@ -867,7 +868,7 @@ def create_table(
867868 def create_table_transaction (
868869 self ,
869870 identifier : str | Identifier ,
870- schema : Union [ Schema , " pa.Schema" ] ,
871+ schema : Schema | pa .Schema ,
871872 location : str | None = None ,
872873 partition_spec : PartitionSpec = UNPARTITIONED_PARTITION_SPEC ,
873874 sort_order : SortOrder = UNSORTED_SORT_ORDER ,
@@ -888,10 +889,10 @@ def create_table_transaction(
888889 @retry (** _RETRY_ARGS )
889890 def create_view (
890891 self ,
891- identifier : Union [ str , Identifier ] ,
892- schema : Union [ Schema , " pa.Schema" ] ,
892+ identifier : str | Identifier ,
893+ schema : Schema | pa .Schema ,
893894 view_version : ViewVersion ,
894- location : Optional [ str ] = None ,
895+ location : str | None = None ,
895896 properties : Properties = EMPTY_DICT ,
896897 ) -> View :
897898 iceberg_schema = self ._convert_schema_if_needed (schema )
0 commit comments