3535from pydantic import Field
3636from sortedcontainers import SortedList
3737
38- from pyiceberg .exceptions import CommitFailedException
3938import pyiceberg .expressions .parser as parser
39+ from pyiceberg .exceptions import CommitFailedException
4040from pyiceberg .expressions import (
4141 AlwaysFalse ,
4242 AlwaysTrue ,
@@ -292,7 +292,7 @@ class Transaction:
292292 _autocommit : bool
293293 _updates : tuple [TableUpdate , ...]
294294 _requirements : tuple [TableRequirement , ...]
295- _pending_updates : list [_StaticUpdate | UpdateTableMetadata ]
295+ _pending_updates : list [_StaticUpdate | UpdateTableMetadata [ Any ] ]
296296 # NOTE: Whenever _updates is modified, _working_metadata must be updated via update_table_metadata()
297297 _working_metadata : TableMetadata
298298
@@ -328,7 +328,7 @@ def _apply(
328328 self ,
329329 updates : tuple [TableUpdate , ...],
330330 requirements : tuple [TableRequirement , ...] = (),
331- pending_update : _StaticUpdate | UpdateTableMetadata | None = None ,
331+ pending_update : _StaticUpdate | UpdateTableMetadata [ Any ] | None = None ,
332332 ) -> Transaction :
333333 """Check if the requirements are met, and applies the updates to the metadata."""
334334 for requirement in requirements :
@@ -340,12 +340,12 @@ def _apply(
340340
341341 # For the requirements, it does not make sense to add a requirement more than once
342342 # For example, you cannot assert that the current schema has two different IDs
343- existing_requirements = {req .key () for req in self ._requirements }
343+ existing_requirement_keys = {req .key () for req in self ._requirements }
344344 for new_requirement in requirements :
345345 key = new_requirement .key ()
346- if key not in existing_requirements :
346+ if key not in existing_requirement_keys :
347347 self ._requirements += (new_requirement ,)
348- existing_requirements .add (key )
348+ existing_requirement_keys .add (key )
349349
350350 if pending_update is not None :
351351 self ._pending_updates .append (pending_update )
@@ -1034,7 +1034,6 @@ def _commit_with_retry(self) -> None:
10341034 On retry, refreshes table metadata and regenerates snapshots from
10351035 the pending snapshot producers.
10361036 """
1037-
10381037 properties = self ._table .metadata .properties
10391038
10401039 retry_config = RetryConfig (
@@ -1116,12 +1115,15 @@ def _reapply_updates(self) -> None:
11161115 self ._updates += updates
11171116 self ._working_metadata = update_table_metadata (self ._working_metadata , updates )
11181117
1119- existing_requirements = {req .key () for r in self ._requirements }
1118+ existing_requirement_keys : set [tuple [Any , ...]] = set ()
1119+ existing_req : TableRequirement
1120+ for existing_req in self ._requirements :
1121+ existing_requirement_keys .add (existing_req .key ())
11201122 for req in requirements :
11211123 key = req .key ()
1122- if key not in existing_requirements :
1124+ if key not in existing_requirement_keys :
11231125 self ._requirements += (req ,)
1124- existing_requirements .add (key )
1126+ existing_requirement_keys .add (key )
11251127
11261128 self ._requirements += (AssertTableUUID (uuid = self .table_metadata .table_uuid ),)
11271129
0 commit comments