-
Notifications
You must be signed in to change notification settings - Fork 412
Remove Generic from expressions
#2750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! mypy is happy too
sungwy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, but do you think it would make sense to align with your change in expressions/__init__.py and use LiteralValue here?
| def visit_equal(self, term: BoundTerm, literal: Literal[L]) -> T: | |
| def visit_equal(self, term: BoundTerm, literal: LiteralValue) -> T: |
| if TYPE_CHECKING: | ||
| LiteralValue = Literal[Any] | ||
| else: | ||
| LiteralValue = Literal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good one! sorry i merged it before you got a chance to submit your reviews
Looks like Fokko has followed up with #2769 :)
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?