Remove Generic from expressions#2750
Merged
kevinjqliu merged 3 commits intoapache:mainfrom Nov 18, 2025
Merged
Conversation
From the beginning we had these Generic in the expressions system, but it really never worked as we hoped. It came from Java where Generics are much stronger, but the static typing of Python/mypy doesn't really follow the types.
kevinjqliu
approved these changes
Nov 18, 2025
Contributor
kevinjqliu
left a comment
There was a problem hiding this comment.
LGTM! mypy is happy too
sungwy
reviewed
Nov 18, 2025
Collaborator
sungwy
left a comment
There was a problem hiding this comment.
Thank you for the PR @Fokko !
I think @kevinjqliu beat me to the punch while I was reviewing it, but I left some comments. 😄
|
|
||
| @abstractmethod | ||
| def visit_equal(self, term: BoundTerm[L], literal: Literal[L]) -> T: | ||
| def visit_equal(self, term: BoundTerm, literal: Literal[L]) -> T: |
Collaborator
There was a problem hiding this comment.
nit, but do you think it would make sense to align with your change in expressions/__init__.py and use LiteralValue here?
Suggested change
| def visit_equal(self, term: BoundTerm, literal: Literal[L]) -> T: | |
| def visit_equal(self, term: BoundTerm, literal: LiteralValue) -> T: |
Comment on lines
+39
to
+42
| if TYPE_CHECKING: | ||
| LiteralValue = Literal[Any] | ||
| else: | ||
| LiteralValue = Literal |
Collaborator
There was a problem hiding this comment.
What are your thoughts on moving this to pyiceberg.typedef instead? I think that'll allow it to be reused by other modules for static type checking.
Contributor
There was a problem hiding this comment.
good one! sorry i merged it before you got a chance to submit your reviews
Looks like Fokko has followed up with #2769 :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
This is a big one, and was on my mind for a long time, but I think we should clean this up before a 1.x release.
I bumped into this once more when I tried to extend from the
IcebergBaseModel, but that did not work well with theGeneric.From the beginning we had these Generic in the expressions system, but it really never worked as we hoped. It came from Java where Generics are much stronger, but the static typing of Python/mypy doesn't really follow the types.
Are these changes tested?
Are there any user-facing changes?