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
@@ -112,7 +113,7 @@ def __str__(self) -> str:
112113 return f"{ self .http_method .value } { self .path } "
113114
114115 @classmethod
115- def from_string (cls , endpoint : str ) -> " Endpoint" :
116+ def from_string (cls , endpoint : str ) -> Endpoint :
116117 elements = endpoint .strip ().split (None , 1 )
117118 if len (elements ) != 2 :
118119 raise ValueError (f"Invalid endpoint (must consist of two elements separated by a single space): { endpoint } " )
@@ -263,7 +264,7 @@ class TableResponse(IcebergBaseModel):
263264
264265
265266class ViewResponse (IcebergBaseModel ):
266- metadata_location : Optional [ str ] = Field (alias = "metadata-location" , default = None )
267+ metadata_location : str | None = Field (alias = "metadata-location" , default = None )
267268 metadata : ViewMetadata
268269 config : Properties = Field (default_factory = dict )
269270
@@ -285,13 +286,13 @@ def transform_properties_dict_value_to_str(cls, properties: Properties) -> dict[
285286
286287class CreateViewRequest (IcebergBaseModel ):
287288 name : str = Field ()
288- location : Optional [ str ] = Field ()
289+ location : str | None = Field ()
289290 view_schema : Schema = Field (alias = "schema" )
290291 view_version : ViewVersion = Field (alias = "view-version" )
291292 properties : Properties = Field (default_factory = dict )
292293
293294 @field_validator ("properties" , mode = "before" )
294- def transform_properties_dict_value_to_str (cls , properties : Properties ) -> Dict [str , str ]:
295+ def transform_properties_dict_value_to_str (cls , properties : Properties ) -> dict [str , str ]:
295296 return transform_dict_value_to_str (properties )
296297
297298
@@ -773,7 +774,7 @@ def _response_to_staged_table(self, identifier_tuple: tuple[str, ...], table_res
773774 catalog = self ,
774775 )
775776
776- def _response_to_view (self , identifier_tuple : Tuple [str , ...], view_response : ViewResponse ) -> View :
777+ def _response_to_view (self , identifier_tuple : tuple [str , ...], view_response : ViewResponse ) -> View :
777778 return View (
778779 identifier = identifier_tuple ,
779780 metadata = view_response .metadata ,
@@ -798,7 +799,7 @@ def _config_headers(self, session: Session) -> None:
798799 def _create_table (
799800 self ,
800801 identifier : str | Identifier ,
801- schema : Union [ Schema , " pa.Schema" ] ,
802+ schema : Schema | pa .Schema ,
802803 location : str | None = None ,
803804 partition_spec : PartitionSpec = UNPARTITIONED_PARTITION_SPEC ,
804805 sort_order : SortOrder = UNSORTED_SORT_ORDER ,
@@ -841,7 +842,7 @@ def _create_table(
841842 def create_table (
842843 self ,
843844 identifier : str | Identifier ,
844- schema : Union [ Schema , " pa.Schema" ] ,
845+ schema : Schema | pa .Schema ,
845846 location : str | None = None ,
846847 partition_spec : PartitionSpec = UNPARTITIONED_PARTITION_SPEC ,
847848 sort_order : SortOrder = UNSORTED_SORT_ORDER ,
@@ -862,7 +863,7 @@ def create_table(
862863 def create_table_transaction (
863864 self ,
864865 identifier : str | Identifier ,
865- schema : Union [ Schema , " pa.Schema" ] ,
866+ schema : Schema | pa .Schema ,
866867 location : str | None = None ,
867868 partition_spec : PartitionSpec = UNPARTITIONED_PARTITION_SPEC ,
868869 sort_order : SortOrder = UNSORTED_SORT_ORDER ,
@@ -883,10 +884,10 @@ def create_table_transaction(
883884 @retry (** _RETRY_ARGS )
884885 def create_view (
885886 self ,
886- identifier : Union [ str , Identifier ] ,
887- schema : Union [ Schema , " pa.Schema" ] ,
887+ identifier : str | Identifier ,
888+ schema : Schema | pa .Schema ,
888889 view_version : ViewVersion ,
889- location : Optional [ str ] = None ,
890+ location : str | None = None ,
890891 properties : Properties = EMPTY_DICT ,
891892 ) -> View :
892893 iceberg_schema = self ._convert_schema_if_needed (schema )
0 commit comments