Skip to content

ENH: Improve typing for Interval #391

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

Merged
merged 16 commits into from
Nov 24, 2022
Merged

Conversation

bashtage
Copy link
Contributor

  • Tests added: Please use assert_type() to assert the type of any return value

xref #383

@bashtage bashtage requested a review from Dr-Irv October 19, 2022 13:23
Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good. Ping when green and those issues have been addressed.

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Oct 24, 2022

ping when green and when issues have been addressed.

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Nov 20, 2022

@bashtage checking on status of this. It was in pretty good shape, just needs to go green and address a few issues.

@bashtage
Copy link
Contributor Author

@Dr-Irv green ex nightly.

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Nov 23, 2022

@Dr-Irv green ex nightly.

will review soon, but I fixed nightly and need you to review in #436

@bashtage
Copy link
Contributor Author

Didn't see this as fixed?

Pretty sure these are gone. When I search for def __gt__(self, other: object) -> bool there are no matches. GH also says outdated.

@bashtage
Copy link
Contributor Author

@Dr-Irv Should be all fixed now.

Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more things

def __eq__(self, other: IntervalT | IntervalIndex[IntervalT]) -> np_ndarray_bool: ... # type: ignore[misc]
@overload
def __eq__(self, other: pd.Series[IntervalT]) -> pd.Series[bool]: ... # type: ignore[misc]
@overload
def __eq__(self, other: object) -> Literal[False]: ...
def __eq__(self, other: object) -> Never: ...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should remain Literal[False], because it is always valid code to do equality against another object.

npt.NDArray[np.float64],
pd.Series[float],
pd.Float64Index,
]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the use of pd.Int64Index and pd.Float64Index here will cause issues with the nightly builds once #436 is merged in, so we'll have to figure out how to deal with that when in a Union like this.

np.ndarray,
np.bool_,
)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to add tests that check that the typing is not too wide. Don't have to do it for this PR. E.g., interval_i >= pd.Timestamp("2017-01-01") should be disallowed.

Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @bashtage

@Dr-Irv Dr-Irv merged commit dc9a094 into pandas-dev:main Nov 24, 2022
@bashtage bashtage deleted the scalars-interval branch November 28, 2022 06:39
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.

2 participants