1919import codecs
2020import gzip
2121from abc import ABC , abstractmethod
22- from typing import TYPE_CHECKING , Callable
22+ from typing import Callable
2323
2424from pyiceberg .io import InputFile , InputStream , OutputFile
25+ from pyiceberg .table .metadata import TableMetadata , TableMetadataUtil
2526from pyiceberg .typedef import UTF8
2627from pyiceberg .utils .config import Config
2728
28- if TYPE_CHECKING :
29- from pyiceberg .table .metadata import TableMetadata
30-
3129GZIP = "gzip"
3230
3331
@@ -81,7 +79,7 @@ class FromByteStream:
8179 @staticmethod
8280 def table_metadata (
8381 byte_stream : InputStream , encoding : str = UTF8 , compression : Compressor = NOOP_COMPRESSOR
84- ) -> " TableMetadata" :
82+ ) -> TableMetadata :
8583 """Instantiate a TableMetadata object from a byte stream.
8684
8785 Args:
@@ -94,16 +92,14 @@ def table_metadata(
9492 json_bytes = reader (byte_stream )
9593 metadata = json_bytes .read ()
9694
97- from pyiceberg .table .metadata import TableMetadataUtil
98-
9995 return TableMetadataUtil .parse_raw (metadata )
10096
10197
10298class FromInputFile :
10399 """A collection of methods that deserialize InputFiles into Iceberg objects."""
104100
105101 @staticmethod
106- def table_metadata (input_file : InputFile , encoding : str = UTF8 ) -> " TableMetadata" :
102+ def table_metadata (input_file : InputFile , encoding : str = UTF8 ) -> TableMetadata :
107103 """Create a TableMetadata instance from an input file.
108104
109105 Args:
@@ -124,7 +120,7 @@ class ToOutputFile:
124120 """A collection of methods that serialize Iceberg objects into files given an OutputFile instance."""
125121
126122 @staticmethod
127- def table_metadata (metadata : " TableMetadata" , output_file : OutputFile , overwrite : bool = False ) -> None :
123+ def table_metadata (metadata : TableMetadata , output_file : OutputFile , overwrite : bool = False ) -> None :
128124 """Write a TableMetadata instance to an output file.
129125
130126 Args:
0 commit comments