-
-
Notifications
You must be signed in to change notification settings - Fork 144
fix: #1304 add PD_LTE_23 #1306
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
fix: #1304 add PD_LTE_23 #1306
Conversation
@@ -140,12 +143,24 @@ def test_truediv_pd_series() -> None: | |||
check(assert_type(left.rdiv(c), pd.Series), pd.Series) | |||
|
|||
|
|||
def test_path_div() -> None: | |||
# GH 682 | |||
folder = Path.cwd() |
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.
Same about the use of ensure_clean
, the rest is good.
948e493
to
935b475
Compare
/nightly |
/pandas_nightly |
Looks like it is failing for nightly run with pandas 3.0 for the test_truediv_path, see https://github.com/pandas-dev/pandas-stubs/actions/runs/16727359383 |
I see the issue, in pandas 3.0 the default type is StringDtype and not object which does not support the div operator. If you do |
I tested locally like that, and ALL of those tests are failing with the nightly. Thanks @loicdiridollou for remembering the right "/" command! |
Yes, all of those tests need to be wrapped this way until the bug is fixed in pandas. That's why the comment as a ref to the pandas Github issue. |
|
||
check(assert_type(left.truediv(p), pd.Series), pd.Series, Path) | ||
check(assert_type(left.div(p), pd.Series), pd.Series, Path) | ||
if PD_LTE_23 or not WINDOWS: |
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.
The or not WINDOWS
should not be necessary.
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.
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.
ping when green. use the "/" command to test nightly.
e9877aa
to
ce7498a
Compare
/pandas_nightly |
Hi @Dr-Irv , it seeems that I cannot trigger the nightly test. |
You have triggered them @cmp0xff, see https://github.com/pandas-dev/pandas-stubs/pull/1306/checks?check_run_id=47350577240 |
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.
One minor thing to confirm but all CI pass so good on my end, thanks @cmp0xff !
check(assert_type(left.rtruediv(p), pd.Series), pd.Series, Path) | ||
check(assert_type(left.rdiv(p), pd.Series), pd.Series, Path) | ||
# mypy thinks it's `Path`, in contrast to Series.__rtruediv__(self, other: Path) -> Series: ... | ||
check(assert_type(tmp_path / fpaths, pd.Series), pd.Series, Path) # type: ignore[assert-type] |
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.
@Dr-Irv will confirm but I think this is an issue we have had in the past with mypy getting confused
|
||
check(assert_type(left.rtruediv(p), pd.Series), pd.Series, Path) | ||
check(assert_type(left.rdiv(p), pd.Series), pd.Series, Path) | ||
# mypy thinks it's `Path`, in contrast to Series.__rtruediv__(self, other: Path) -> Series: ... |
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 tried to come up with a simple example to illustrate the issue and couldn't.
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.
Issue comes from how mypy reads the Path.__truediv__
typing and it prioritizes it over Series.rtruediv, not expert enough to know why
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, I don't know why it did that. Tried some simple experiments and couldn't replicate it.
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 @cmp0xff
assert_type()
to assert the type of any return value