Skip to content

Conversation

@Dr-Irv
Copy link
Contributor

@Dr-Irv Dr-Irv commented Feb 18, 2022

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 and Timedelta by taking them from the pandas distribution to fix other issues.

@property
@overload
def left(self: Interval[Orderable]) -> Orderable: ...
def left(self: Interval[OrderableT]) -> Orderable: ...

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: ...

Copy link
Contributor Author

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.

) -> Interval[int]: ...
@overload
def length(self: Interval[Orderable]) -> Orderable: ...
def __new__(

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]: ...

Copy link
Contributor Author

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.

@gramster gramster merged commit 1e1b828 into microsoft:main Feb 23, 2022
@Dr-Irv Dr-Irv deleted the interval branch February 23, 2022 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants