Skip to content

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

Merged
merged 4 commits into from
Aug 4, 2025
Merged

Conversation

cmp0xff
Copy link
Contributor

@cmp0xff cmp0xff commented Aug 3, 2025

@@ -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()
Copy link
Member

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.

cmp0xff added a commit to cmp0xff/pandas-stubs that referenced this pull request Aug 3, 2025
cmp0xff added a commit to cmp0xff/pandas-stubs that referenced this pull request Aug 3, 2025
@cmp0xff cmp0xff force-pushed the hotfix/cmp0xff/1304 branch 2 times, most recently from 948e493 to 935b475 Compare August 3, 2025 18:31
@cmp0xff cmp0xff marked this pull request as draft August 3, 2025 18:31
@cmp0xff cmp0xff marked this pull request as ready for review August 4, 2025 14:51
@cmp0xff cmp0xff requested a review from loicdiridollou August 4, 2025 14:56
@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Aug 4, 2025

/nightly

@loicdiridollou
Copy link
Member

/pandas_nightly

@loicdiridollou
Copy link
Member

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
You can run those tests locally with poetry run poe pytest —nightly

@loicdiridollou
Copy link
Member

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 left.astype(object) / p you won’t have the issue. So I would wrap the test with PD_LTE_23 since it is not supported with pandas 3.0 as the dtype of the series is changing, but @Dr-Irv can confirm.

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Aug 4, 2025

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 You can run those tests locally with poetry run poe pytest —nightly

I tested locally like that, and ALL of those tests are failing with the nightly.

Thanks @loicdiridollou for remembering the right "/" command!

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Aug 4, 2025

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 left.astype(object) / p you won’t have the issue. So I would wrap the test with PD_LTE_23 since it is not supported with pandas 3.0 as the dtype of the series is changing, but @Dr-Irv can confirm.

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:
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

ping when green. use the "/" command to test nightly.

@cmp0xff cmp0xff marked this pull request as draft August 4, 2025 16:05
cmp0xff added a commit to cmp0xff/pandas-stubs that referenced this pull request Aug 4, 2025
@cmp0xff cmp0xff force-pushed the hotfix/cmp0xff/1304 branch from e9877aa to ce7498a Compare August 4, 2025 16:12
@cmp0xff
Copy link
Contributor Author

cmp0xff commented Aug 4, 2025

/pandas_nightly

@cmp0xff cmp0xff marked this pull request as ready for review August 4, 2025 16:20
@cmp0xff cmp0xff requested a review from Dr-Irv August 4, 2025 16:20
@cmp0xff
Copy link
Contributor Author

cmp0xff commented Aug 4, 2025

Hi @Dr-Irv , it seeems that I cannot trigger the nightly test.

@loicdiridollou
Copy link
Member

You have triggered them @cmp0xff, see https://github.com/pandas-dev/pandas-stubs/pull/1306/checks?check_run_id=47350577240

Copy link
Member

@loicdiridollou loicdiridollou left a 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]
Copy link
Member

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: ...
Copy link
Collaborator

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.

Copy link
Member

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

Copy link
Collaborator

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.

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 @cmp0xff

@Dr-Irv Dr-Irv merged commit 1fa75e8 into pandas-dev:main Aug 4, 2025
14 checks passed
@cmp0xff cmp0xff deleted the hotfix/cmp0xff/1304 branch August 5, 2025 07:49
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.

Reinstate test for Path.truediv that fails with 3.0
3 participants