19
19
import time
20
20
from collections import defaultdict
21
21
from enum import Enum
22
- from typing import TYPE_CHECKING , Any , DefaultDict , Dict , Iterable , List , Mapping , Optional
22
+ from typing import TYPE_CHECKING , Any , DefaultDict , Dict , Iterable , List , Mapping , Optional , Tuple
23
23
24
24
from cachetools import LRUCache , cached
25
25
from cachetools .keys import hashkey
@@ -233,10 +233,10 @@ def __eq__(self, other: Any) -> bool:
233
233
234
234
235
235
@cached (cache = LRUCache (maxsize = 128 ), key = lambda io , manifest_list : hashkey (manifest_list ))
236
- def _manifests (io : FileIO , manifest_list : str ) -> List [ManifestFile ]:
237
- """Return the manifests from the manifest list."""
236
+ def _manifests (io : FileIO , manifest_list : str ) -> Tuple [ManifestFile , ... ]:
237
+ """Read and cache manifests from the given manifest list, returning a tuple to prevent modification ."""
238
238
file = io .new_input (manifest_list )
239
- return list (read_manifest_list (file ))
239
+ return tuple (read_manifest_list (file ))
240
240
241
241
242
242
class Snapshot (IcebergBaseModel ):
@@ -261,7 +261,7 @@ def __str__(self) -> str:
261
261
def manifests (self , io : FileIO ) -> List [ManifestFile ]:
262
262
"""Return the manifests for the given snapshot."""
263
263
if self .manifest_list :
264
- return _manifests (io , self .manifest_list )
264
+ return list ( _manifests (io , self .manifest_list ) )
265
265
return []
266
266
267
267
0 commit comments