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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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.

@@ -1579,6 +1584,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
periods: int = ...,
fill_method: None = ...,
freq: DateOffset | timedelta | _str | None = ...,
limit: int | None = ..., # deprecated since 2.1
Copy link
Member

Choose a reason for hiding this comment

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

not sure if we want to add a deprecated argument. If we add it, we could add it with just its default value limit: None

Copy link
Collaborator

Choose a reason for hiding this comment

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

we shouldn't add deprecated arguments. so remove this

@@ -14,5 +15,9 @@ def read_parquet(
engine: ParquetEngine = ...,
columns: list[str] | None = ...,
storage_options: StorageOptions = ...,
use_nullable_dtypes: bool = ..., # deprecated since 2.0
Copy link
Member

Choose a reason for hiding this comment

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

can probably be removed

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 agree. Should remove.

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

@@ -1217,7 +1222,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
def droplevel(self, level: Level | list[Level], axis: AxisIndex = ...) -> Self: ...
def pop(self, item: Hashable) -> S1: ...
@final
def squeeze(self) -> Series[S1] | Scalar: ...
def squeeze(self, axis: Axis = ...) -> Series[S1] | Scalar: ...
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
def squeeze(self, axis: Axis = ...) -> Series[S1] | Scalar: ...
def squeeze(self, axis: None = ...) -> Series[S1] | Scalar: ...

The only valid value here is None for axis

@@ -1579,6 +1584,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
periods: int = ...,
fill_method: None = ...,
freq: DateOffset | timedelta | _str | None = ...,
limit: int | None = ..., # deprecated since 2.1
Copy link
Collaborator

Choose a reason for hiding this comment

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

we shouldn't add deprecated arguments. so remove this

@@ -14,5 +15,9 @@ def read_parquet(
engine: ParquetEngine = ...,
columns: list[str] | None = ...,
storage_options: StorageOptions = ...,
use_nullable_dtypes: bool = ..., # deprecated since 2.0
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 agree. Should remove.

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

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