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

fix(python): Remove incorrect warning when using an IO[bytes] instance #19154

Merged
merged 1 commit into from
Oct 10, 2024

Conversation

adamreeve
Copy link
Contributor

Fixes #18417

When passing something like a gzip.GzipFile or zipfile.ZipExtFile, it's not possible to pass a file path instead. And since #17315, Polars will extract the underlying fileno for faster IO performance if possible, so it doesn't appear that this warning is useful any more.

@adamreeve adamreeve changed the title fix(Python): Remove incorrect warning when using an IO[bytes] instance fix(python): Remove incorrect warning when using an IO[bytes] instance Oct 9, 2024
@github-actions github-actions bot added fix Bug fix python Related to Python Polars and removed title needs formatting labels Oct 9, 2024
Copy link

codecov bot commented Oct 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.78%. Comparing base (ee9bafb) to head (70acf7b).
Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #19154   +/-   ##
=======================================
  Coverage   79.78%   79.78%           
=======================================
  Files        1531     1531           
  Lines      208449   208431   -18     
  Branches     2913     2913           
=======================================
- Hits       166317   166303   -14     
+ Misses      41581    41577    -4     
  Partials      551      551           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@coastalwhite
Copy link
Collaborator

This warning might need to stay for windows.

@miccoli
Copy link

miccoli commented Oct 10, 2024

I fear I do not completely understand in which this situations this warning is meaningful.

If it's only to nudge a user to rewrite

with open(foobar, 'rb') as fp:
    df = pl.read_csv(fp)

as

df = pl.read_csv(foobar)

then a runtime user warning is overkill, in my opinion.

Please give me the opportunity to shoot myself in the foot without adding the annoyance of a warning!
More seriously, I think that only a very small number of polars user can benefit from this warning, so better drop it, and instead add a line in the user docs.

If there are other non-trivial situations in which this warning is useful, please forgive me for the added noise to this thread.

@ritchie46 ritchie46 merged commit 194b31e into pola-rs:main Oct 10, 2024
21 of 22 checks passed
@adamreeve adamreeve deleted the remove_warning branch October 10, 2024 21:25
@adamreeve
Copy link
Contributor Author

This warning might need to stay for windows.

I initially missed that the fileno optimisation was Unix only, but I still agree with @miccoli that the benefit of the warning seems minimal and it's probably more effort than it's worth to fix the false positives and detect when a file path could have been used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix python Related to Python Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

write_csv raises a UserWarning when writing to gzip compressed file
4 participants