Skip to content

DOC: missing path-like at path parameter in to_pickle() #46081

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

Closed
1 task done
simon-spier0 opened this issue Feb 20, 2022 · 2 comments · Fixed by #46262
Closed
1 task done

DOC: missing path-like at path parameter in to_pickle() #46081

simon-spier0 opened this issue Feb 20, 2022 · 2 comments · Fixed by #46262
Labels
Docs Typing type annotations, mypy/pyright type checking

Comments

@simon-spier0
Copy link

Pandas version checks

  • I have checked that the issue still exists on the latest versions of the docs on main here

Location of the documentation

https://pandas.pydata.org/docs/dev/reference/api/pandas.DataFrame.to_pickle.html

Documentation problem

Based on documentation, it accepts parameter path as str. Inside the to_pickle(), the path parameter is put to stringify_path() so it accepts path-like object actually.

Suggested fix for documentation

Adding path-like object to documentation removes warning in PyCharm.
image

@simon-spier0 simon-spier0 added Docs Needs Triage Issue that has not been reviewed by a pandas team member labels Feb 20, 2022
@simon-spier0 simon-spier0 changed the title DOC: DOC: missing path-like at path parameter in to_pickle() Feb 20, 2022
@simonjayhawkins simonjayhawkins added this to the Contributions Welcome milestone Feb 20, 2022
@simonjayhawkins simonjayhawkins added Typing type annotations, mypy/pyright type checking and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Feb 20, 2022
@simonjayhawkins
Copy link
Member

Thanks @simon-spier0 for the report.

The path parameter of NDFrame.to_pickle is also missing a type annotation to match the docstring.

pandas/pandas/core/generic.py

Lines 2968 to 2971 in afc06e7

def to_pickle(
self,
path,
compression: CompressionOptions = "infer",

Inside the to_pickle(), the path parameter is put to stringify_path() so it accepts path-like object actually.

NDFrame.to_pickle dispatches to to_pickle in pandas/io/pickle.py where the accepted types are defined as filepath_or_buffer: FilePath | WriteBuffer[bytes]. (FilePath is defined in pandas._typing as FilePath = Union[str, "PathLike[str]"])

The type annotation for path in DataFrame.to_pickle should match the type annotation for filepath_or_buffer in pandas.io.pickle.to_pickle and should match the docstring too

contributions welcome.

@marco-georgaklis
Copy link

take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants