pandas: get types of Interval correct#167
Merged
gramster merged 9 commits intomicrosoft:mainfrom Feb 23, 2022
Merged
Conversation
twoertwein
reviewed
Feb 20, 2022
partial/pandas/_libs/interval.pyi
Outdated
| @property | ||
| @overload | ||
| def left(self: Interval[Orderable]) -> Orderable: ... | ||
| def left(self: Interval[OrderableT]) -> Orderable: ... |
There was a problem hiding this comment.
Are all the overloads needed for left/right? I think this might be enough:
def left(self: Interval[OrderableT]) -> OrderableT: ...
def right(self: Interval[OrderableT]) -> OrderableT: ...
Contributor
Author
There was a problem hiding this comment.
Are all the overloads needed for
left/right? I think this might be enough:def left(self: Interval[OrderableT]) -> OrderableT: ... def right(self: Interval[OrderableT]) -> OrderableT: ...
Yes, that is correct. Changed in next commit.
twoertwein
reviewed
Feb 20, 2022
partial/pandas/_libs/interval.pyi
Outdated
| ) -> Interval[int]: ... | ||
| @overload | ||
| def length(self: Interval[Orderable]) -> Orderable: ... | ||
| def __new__( |
There was a problem hiding this comment.
and the same for __new__
def __new__(
cls,
left: OrderableT,
right: OrderableT,
closed: Literal["left", "right", "both", "neither"] = ...,
) -> Interval[OrderableT]: ...
Contributor
Author
There was a problem hiding this comment.
All of them are needed. That's how you end up with the specific matching of input types to the proper Interval[] subtype. I tried removing them and then length has the wrong type.
gramster
approved these changes
Feb 23, 2022
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.
Interval.lengthis a property that is overloaded, and has a result dependent on the constructor, but you can't do that, so this fixes that issue.Also updated
TimestampandTimedeltaby taking them from the pandas distribution to fix other issues.