-
Notifications
You must be signed in to change notification settings - Fork 1
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
Don't fail if pyarrow is not installed. #6
Conversation
Since this doesn't directly depend upon pyarrow, it is possible that some end-user code does `import pyarrow_hotfix` as a defense mechanism, despite not needing `pyarrow_hotfix` itself. If this happens, it should not be a failure.
I don't have a strong opinion on this, but I'm a bit wary of potential mishaps due to silently silencing the error. Since this is a security feature, I'd rather be strict here. cc @jorisvandenbossche for opinions |
An advantage of this is that it makes it easier to adopt in case you only have an optional dependency on pyarrow; you can just import it without having to care about pyarrow being available or not. However, I think it is also rather easy to get this as well by just only importing this where you import pyarrow (at least for a library depending on the hotfix package, that should be easy I think). |
The case I am thinking of is generally the "second-level" dependency of Arrow on the part of either a library developer or an end developer. Let's say that I as a library developer have If Similarly, if I as an end developer depend upon Both of these may be somewhat of corner cases, and honestly I completely understand if you would prefer not to accommodate them directly for other reasons. Alternately, a really short justification might be "if your library does not depend upon another library, the other library's absence should not cause any problems," but again I understand that this particular library is kind of a special case. Either way, hopefully this at least makes clear what was going through my head when writing this. |
Personally I am fine with this change if it helps adopting the hotfix package. |
Ok, if this is desirable, can a test be added for it? |
src/pyarrow_hotfix/__init__.py
Outdated
import pyarrow as pa | ||
try: | ||
import pyarrow as pa | ||
except ImportError: |
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.
Should this be ModuleNotFoundError
?
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.
Good idea. Changed here and below.
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.
Test added as well.
src/pyarrow_hotfix/__init__.py
Outdated
import pyarrow as pa | ||
try: | ||
import pyarrow as pa | ||
except ImportError: |
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.
Good idea. Changed here and below.
Ow, sorry: |
one more round! |
Thanks @thetorpedodog ! I've released 0.6 with this change. |
Since this doesn't directly depend upon pyarrow, it is possible that some end-user code does
import pyarrow_hotfix
as a defense mechanism, despite not needingpyarrow_hotfix
itself. If this happens, it should not be a failure.This is a simple proposal to take or leave; it also may be reasonable to add a warning that Arrow isn’t installed.