-
Notifications
You must be signed in to change notification settings - Fork 3k
Python: Remove mypy error #4728
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,10 +64,10 @@ def __repr__(self): | |
| def __str__(self): | ||
| return self._transform_string | ||
|
|
||
| def __call__(self, value: S) -> Optional[T]: | ||
| def __call__(self, value: Optional[S]) -> Optional[T]: | ||
| return self.apply(value) | ||
|
|
||
| def apply(self, value: S) -> Optional[T]: | ||
| def apply(self, value: Optional[S]) -> Optional[T]: | ||
| ... | ||
|
|
||
| def can_transform(self, source: IcebergType) -> bool: | ||
|
|
@@ -83,10 +83,8 @@ def preserves_order(self) -> bool: | |
| def satisfies_order_of(self, other) -> bool: | ||
| return self == other | ||
|
|
||
| def to_human_string(self, value) -> str: | ||
| if value is None: | ||
| return "null" | ||
| return str(value) | ||
| def to_human_string(self, value: Optional[S]) -> str: | ||
| return str(value) if value is not None else "null" | ||
|
|
||
| @property | ||
| def dedup_name(self) -> str: | ||
|
|
@@ -119,11 +117,8 @@ def num_buckets(self) -> int: | |
| def hash(self, value: S) -> int: | ||
| raise NotImplementedError() | ||
|
|
||
| def apply(self, value: S) -> Optional[int]: | ||
| if value is None: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we have if not value:I've removed it for now, because according to the current definition it is unreachable code.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, looking at the tests, we might expect a
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, transforms can be applied to optional columns so this should be |
||
| return None | ||
|
|
||
| return (self.hash(value) & IntegerType.max) % self._num_buckets | ||
| def apply(self, value: Optional[S]) -> Optional[int]: | ||
| return (self.hash(value) & IntegerType.max) % self._num_buckets if value else None | ||
|
|
||
| def result_type(self, source: IcebergType) -> IcebergType: | ||
| return IntegerType() | ||
|
|
||
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.
Is this change necessary for this PR? We generally try to avoid code churn that isn't making functional changes.