2121from abc import ABC , abstractmethod
2222from collections .abc import Callable , Iterable , Sequence
2323from functools import cached_property
24- from typing import TYPE_CHECKING , Any , cast
24+ from typing import Any
2525from typing import Literal as TypingLiteral
2626
2727from pydantic import ConfigDict , Field
2828
2929from pyiceberg .expressions .literals import AboveMax , BelowMin , Literal , literal
3030from pyiceberg .schema import Accessor , Schema
31- from pyiceberg .typedef import IcebergBaseModel , IcebergRootModel , L , StructProtocol
31+ from pyiceberg .typedef import IcebergBaseModel , IcebergRootModel , L , LiteralValue , StructProtocol
3232from pyiceberg .types import DoubleType , FloatType , NestedField
3333from pyiceberg .utils .singleton import Singleton
3434
35- try :
36- from pydantic import ConfigDict
37- except ImportError :
38- ConfigDict = dict
39-
40- if TYPE_CHECKING :
41- LiteralValue = Literal [Any ]
42- else :
43- LiteralValue = Literal
44-
4535
4636def _to_unbound_term (term : str | UnboundTerm ) -> UnboundTerm :
4737 return Reference (term ) if isinstance (term , str ) else term
@@ -606,7 +596,7 @@ class SetPredicate(IcebergBaseModel, UnboundPredicate, ABC):
606596 model_config = ConfigDict (arbitrary_types_allowed = True )
607597
608598 type : TypingLiteral ["in" , "not-in" ] = Field (default = "in" )
609- literals : set [Any ] = Field (alias = "items" )
599+ literals : set [LiteralValue ] = Field (alias = "items" )
610600
611601 def __init__ (self , term : str | UnboundTerm , literals : Iterable [Any ] | Iterable [LiteralValue ]):
612602 literal_set = _to_literal_set (literals )
@@ -615,7 +605,7 @@ def __init__(self, term: str | UnboundTerm, literals: Iterable[Any] | Iterable[L
615605
616606 def bind (self , schema : Schema , case_sensitive : bool = True ) -> BoundSetPredicate :
617607 bound_term = self .term .bind (schema , case_sensitive )
618- literal_set = cast ( set [ LiteralValue ], self .literals )
608+ literal_set = self .literals
619609 return self .as_bound (bound_term , {lit .to (bound_term .ref ().field .field_type ) for lit in literal_set })
620610
621611 def __str__ (self ) -> str :
0 commit comments