-
-
Notifications
You must be signed in to change notification settings - Fork 147
refactor: #718 only drop TimestampSeries #1274
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
base: main
Are you sure you want to change the base?
Conversation
c81cd6e
to
d5e1089
Compare
d5e1089
to
41c7015
Compare
abf9147
to
cbbd372
Compare
@cmp0xff you have a number of PRs submitted while I was out on vacation for 2 weeks. Can you let me know which ones I should prioritize for review? |
Hi @Dr-Irv, I hope you had a nice vacation. My pull requests are categorised below. Each category is independent, but those in a higher position have a slightly higher priority in my opinion.
|
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.
Thanks for doing this. It's a lot of good work.
Main thing - if I'm going to merge this PR, it needs to be in a state where we don't need the followup PR.
Basic rule - we don't put ignore
in the tests unless we are testing that the stubs should not accept something that is invalid. You have places where you have added ignore
in the tests and I won't merge that in (unless we know it is a bug in the type checker)
Thank you very much for your quick and thorough reviews. I will be able to work on them next week. |
cbbd372
to
ed69ec5
Compare
b095af2
to
f1cf19f
Compare
Before making this PR as "ready for review", I probably can still clean up the |
check(assert_type(left_ts.rsub(s), pd.Series), pd.Series, pd.Timedelta) | ||
check(assert_type(left_ts.rsub(a), pd.Series), pd.Series, pd.Timedelta) |
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.
datetime - Series[Any]
can either be timedelta
-like or datetime
-like, depending on Any
. I would not give an exact type here.
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.
Yes, that makes sense.
) -> TimestampProperties: ... | ||
@overload | ||
def __get__( | ||
self, instance: Series[Timedelta], owner: Any |
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.
Use TimedeltaSeries
here or TimedeltaSeries | Series[Timedelta]
and then change in the PR that will remove TimedeltaSeries
pandas-stubs/core/series.pyi
Outdated
def __mul__( | ||
self, other: timedelta | Timedelta | TimedeltaSeries | np.timedelta64 | ||
self: Series[bool], | ||
other: timedelta | np.timedelta64 | np_ndarray_td | TimedeltaSeries, | ||
) -> TimedeltaSeries: ... | ||
@overload | ||
def __mul__(self: Series[bool], other: Series[Timedelta]) -> Series[Timedelta]: ... # type: ignore[overload-overlap] | ||
@overload | ||
def __mul__( | ||
self: Series[int], | ||
other: timedelta | np.timedelta64 | np_ndarray_td | TimedeltaSeries, | ||
) -> TimedeltaSeries: ... | ||
@overload | ||
def __mul__(self: Series[int], other: Series[Timedelta]) -> Series[Timedelta]: ... | ||
@overload | ||
def __mul__( | ||
self: Series[float], | ||
other: timedelta | np.timedelta64 | np_ndarray_td | TimedeltaSeries, | ||
) -> TimedeltaSeries: ... | ||
@overload | ||
def __mul__(self: Series[float], other: Series[Timedelta]) -> Series[Timedelta]: ... |
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 it possible to combine these overloads like this?
@overload
def __mul__(
self: Series[bool] | Series[int] | Series[float],
other: timedelta | np.timedelta64 | np_ndarray_td | TimedeltaSeries,
) -> TimedeltaSeries: ...
@overload
def __mul__(self: Series[bool] | Series[int] | Series[float],, other: Series[Timedelta]) -> Series[Timedelta]: ... # type: ignore[overload-overlap]
def median( | ||
self, | ||
self: Series[float], |
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.
self: Series[float], | |
self: Series[float] | Series[int] |
And then for Series[bool]
, median()
returns np.floating
@overload | ||
def to_numpy( | ||
self, | ||
dtype: DTypeLike | None = None, | ||
copy: bool = False, | ||
na_value: Scalar = ..., | ||
**kwargs, | ||
) -> np_1darray: ... |
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.
I don't think you need this overload because IndexOpsMixin
has it. Then you can get rid of the ignore
s in _SeriesSubClassBase
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.
Looked at the most recent version, and found one issue, and there are a few other issues open from previous review. Ping when you want me to look at it.
# checking, where our `__radd__` cannot override. At runtime, they return | ||
# `Series`s. | ||
if TYPE_CHECKING_INVALID_USAGE: | ||
assert_type(i + left, "npt.NDArray[np.int64]") |
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.
any assert_type()
within the if TYPE_CHECKING_INVALID_USAGE
has to have a # type: ignore
in it.
If it fails at runtime, and we can't detect it (which is the case here, I think), then just comment out the test and include a comment indicating why this can't be tested.
TimestampSeries
,TimedeltaSeries
, etc. can be removed #718assert_type()
to assert the type of any return value