Skip to content

Improve results of stubtest #1286

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 3 commits into from
Jul 25, 2025
Merged

Conversation

loicdiridollou
Copy link
Member

Clean up some old pandas 2.2 code that was removed, improved the results of the stubtest.

  • Closes #xxxx (Replace xxxx with the Github issue number)
  • Tests added: Please use assert_type() to assert the type of any return value

Copy link
Member

@twoertwein twoertwein left a comment

Choose a reason for hiding this comment

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

Looks good to me, but I'm a bit unsure about the deprecated arguments.

@loicdiridollou
Copy link
Member Author

Thanks @twoertwein for the review, I was debating myself about the deprecated args, they appear in the stubtest since the code is still there.
Prob worth opening a discussion with @Dr-Irv how we want to handle it, a part of me want to drop them since we should not use them but the stubtest complains. Not sure there is a perfect answer here, the stubtest is super useful as it uncovers many bits of code that were deleted from the pandas code but it of course can't handle deprecation like we would like.

@@ -1132,6 +1135,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
freq: DateOffset | timedelta | _str | None = ...,
axis: Axis = ...,
fill_value: Scalar | NAType | None = ...,
suffix: _str | None = ..., # has no effect at the moment
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably should split into 2 overloads, based on the docs. One is where periods is int and there is no suffix argument, and the other where periods is Sequence[int] and then suffix is allowed.

I don't understand what you mean by "has no effect at the moment"

Copy link
Member Author

@loicdiridollou loicdiridollou Jul 25, 2025

Choose a reason for hiding this comment

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

If you read the source code it is not used at all.
https://github.com/pandas-dev/pandas/blob/4f952b79f91f4f9d4d86b46d34e78dc657bfd4a2/pandas/core/generic.py#L10122-L10130

Maybe I missed something in the code but not sure.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I created pandas-dev/pandas#61955

so let's delete it from the stubs

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Jul 23, 2025

Thanks @twoertwein for the review, I was debating myself about the deprecated args, they appear in the stubtest since the code is still there. Prob worth opening a discussion with @Dr-Irv how we want to handle it, a part of me want to drop them since we should not use them but the stubtest complains. Not sure there is a perfect answer here, the stubtest is super useful as it uncovers many bits of code that were deleted from the pandas code but it of course can't handle deprecation like we would like.

I prefer to not have deprecated arguments in the stubs, because we want people to stop using them.

Maybe there is a way to tell stubtest to ignore certain differences?

@loicdiridollou
Copy link
Member Author

When it comes to stubtest I don't think there is a way for it to filter since the errors that we get is that the arguments in the stubs are misaligned with the runtime version (it is impossible for stubtest to know what is deprecated in pandas).
That is why I felt like reintroducing the arguments would help clear out the errors but as you said it is not the better way to go.

@@ -1132,6 +1135,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
freq: DateOffset | timedelta | _str | None = ...,
axis: Axis = ...,
fill_value: Scalar | NAType | None = ...,
suffix: _str | None = ..., # has no effect at the moment
Copy link
Collaborator

Choose a reason for hiding this comment

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

I created pandas-dev/pandas#61955

so let's delete it from the stubs

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.

@Dr-Irv Dr-Irv merged commit a6755d4 into pandas-dev:main Jul 25, 2025
13 checks passed
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