Skip to content
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

Fixes mypy attribute issue in io/parquet by adding a hasattr check #45570

Merged
merged 10 commits into from
Jan 23, 2022

Conversation

Anirudhsekar96
Copy link
Contributor

pandas/io/parquet.py Outdated Show resolved Hide resolved
@twoertwein
Copy link
Member

Instead of checking for io.BufferedWritter, it might be better to use io.FileIO since it has .name:
https://github.com/python/typeshed/blob/3d28f0981f470a3e94d819705f8a95b77eaee56d/stdlib/io.pyi#L67

Probably would also make sense to change the if condition to if isinstance(path_or_handle, io.FileIO) and isintance(path_or_handle.name, (str, bytes)) as .name could apparently also be an int.

pandas/io/parquet.py Outdated Show resolved Hide resolved
@jreback jreback added IO Parquet parquet, feather Typing type annotations, mypy/pyright type checking labels Jan 23, 2022
pandas/tests/io/test_parquet.py Outdated Show resolved Hide resolved
@jreback jreback added this to the 1.5 milestone Jan 23, 2022
@jreback
Copy link
Contributor

jreback commented Jan 23, 2022

@Anirudhsekar96 great ping on green

Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

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

One comment otherwise LGTM

@jreback
Copy link
Contributor

jreback commented Jan 23, 2022

great ping on green

@Anirudhsekar96
Copy link
Contributor Author

The checks have completed running

@twoertwein twoertwein merged commit 642ef16 into pandas-dev:main Jan 23, 2022
@twoertwein
Copy link
Member

Thank you @Anirudhsekar96

yehoshuadimarsky pushed a commit to yehoshuadimarsky/pandas that referenced this pull request Jul 13, 2022
…andas-dev#45570)

* Fixes mypy attribute issue in io/parquet by adding a hasattr check

* changed attr to name attribute inside raw

* combined the conditional checks on io.BufferedWriter in io/parquet

* changed attribute from raw.name to name and added hasattr check

* Skipped checks for graceful cleanup in windows

* Changed checks for path object in parquet, linted and sorted imports

* Removed sys dependency and changed pytest check for windows

* Changed the condition in io/parquet to hasattr from isinstance of io.FileIO

* Changed the pytest skip condition to decorator and added a message

* Changed pytest skipif to mark.xfail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO Parquet parquet, feather Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants