-
Notifications
You must be signed in to change notification settings - Fork 101
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
pandas: get types of Interval correct #167
Conversation
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: ...
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.
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.
partial/pandas/_libs/interval.pyi
Outdated
@overload | ||
def length(self: Interval[Orderable]) -> Orderable: ... | ||
def __new__( |
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.
and the same for __new__
def __new__(
cls,
left: OrderableT,
right: OrderableT,
closed: Literal["left", "right", "both", "neither"] = ...,
) -> Interval[OrderableT]: ...
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.
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.
Interval.length
is 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
Timestamp
andTimedelta
by taking them from the pandas distribution to fix other issues.