Skip to content

Commit 26c1fd2

Browse files
committed
Follow up on cleaning up the removal of Generic
1 parent 155af26 commit 26c1fd2

File tree

3 files changed

+73
-78
lines changed

3 files changed

+73
-78
lines changed

pyiceberg/expressions/__init__.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,17 @@
2121
from abc import ABC, abstractmethod
2222
from collections.abc import Callable, Iterable, Sequence
2323
from functools import cached_property
24-
from typing import TYPE_CHECKING, Any, cast
24+
from typing import Any
2525
from typing import Literal as TypingLiteral
2626

2727
from pydantic import ConfigDict, Field
2828

2929
from pyiceberg.expressions.literals import AboveMax, BelowMin, Literal, literal
3030
from pyiceberg.schema import Accessor, Schema
31-
from pyiceberg.typedef import IcebergBaseModel, IcebergRootModel, L, StructProtocol
31+
from pyiceberg.typedef import IcebergBaseModel, IcebergRootModel, L, LiteralValue, StructProtocol
3232
from pyiceberg.types import DoubleType, FloatType, NestedField
3333
from 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

4636
def _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

Comments
 (0)