-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DEPS: Add warning if pyarrow is not installed #56896
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
Changes from 6 commits
bb520d1
a3b3dc3
944c288
613eac7
21509c5
c6ae03d
7b48501
199fb7c
4637a96
aa48e19
9999fe3
3aa3ba9
0074b03
cc2debf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -202,8 +202,39 @@ | |||||
FutureWarning, | ||||||
stacklevel=2, | ||||||
) | ||||||
# Don't allow users to use pandas.os or pandas.warnings | ||||||
del os, warnings | ||||||
# Don't allow users to use pandas.os | ||||||
del os | ||||||
|
||||||
# DeprecationWarning for missing pyarrow | ||||||
from pandas.compat.pyarrow import pa_version_under10p1 | ||||||
|
||||||
if pa_version_under10p1: | ||||||
Dr-Irv marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
# Check if old pyarrow is installed | ||||||
from pandas.compat._optional import VERSIONS | ||||||
lithomas1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
try: | ||||||
import pyarrow # noqa: F401 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add an else block to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thx |
||||||
|
||||||
pa_msg = ( | ||||||
f"was too old on your system - pyarrow {VERSIONS['pyarrow']} " | ||||||
"is the current minimum supported version as of this release." | ||||||
) | ||||||
except ImportError: | ||||||
pa_msg = "was not found to be installed on your system." | ||||||
|
||||||
warnings.warn( | ||||||
f""" | ||||||
Pyarrow will become a required dependency of pandas in the next major release of pandas, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I think we can be explicit about what this next major release will be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the next major release also the next minor release, i.e., 2.2 then 3.0? I noticed that the dev wheels recently switched to reporting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, 2.2 is coming out sometime this week. |
||||||
(to allow more performant data types and better interoperability with other libraries) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would maybe explicitly mention the new default string dtype, since that's still the only one that is used by default that requires pyarrow There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. |
||||||
but {pa_msg} | ||||||
If this would cause problems for you, | ||||||
please provide us feedback at https://github.com/pandas-dev/pandas/issues/54466 | ||||||
""", | ||||||
DeprecationWarning, | ||||||
stacklevel=2, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to make this stacklevel=1? Because this code is top-level and not inside a function or method, it one less than the typical stacklevel of 2 we use in a direct function/method. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The warning doesn't pop up in the REPL when I import pandas if I do stacklevel=1. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, OK forget this. I did test it, but should have done something wrong because now I can't reproduce getting the warning with plain import and stacklevel 1 |
||||||
) | ||||||
del VERSIONS | ||||||
del pa_version_under10p1, warnings | ||||||
|
||||||
# module level doc-string | ||||||
__doc__ = """ | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to not run this this at the end with the other modules? Seems like it's easier to maintain if there is all the clean up at the end or next to the import, but no big deal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, not really.
Personally I like to keep the del closed to where it's being used, but no strong preference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
os
is not being used in the code before beibg closed. As said, not important, but to me personally it makes sense to open and close around the block where it is being used, or open and close at the beginning and the end if it's an import that is used in several places. Nowos
is being opened at the beginning, and closed in the middle, in a kind of random place if I'm not wrong. No huge difference, but I think it'll help maintain the code if closed at the end (or we move the import and del around where it is being used).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put the os delete with the deletion of warnings/pa_version_under10p1.