Avoid runtime dependency on numpy when importing arro3.core.types#210
Merged
kylebarron merged 2 commits intokylebarron:mainfrom Oct 2, 2024
Merged
Avoid runtime dependency on numpy when importing arro3.core.types#210kylebarron merged 2 commits intokylebarron:mainfrom
kylebarron merged 2 commits intokylebarron:mainfrom
Conversation
Owner
|
Oops, this was unintentional! Thank you! I was tired and forgot momentarily that |
kylebarron
reviewed
Oct 2, 2024
|
|
||
| # Numpy arrays don't yet declare `__buffer__` (or maybe just on a very recent version) | ||
| ArrayInput = Union[ArrowArrayExportable, BufferProtocolExportable, np.ndarray] | ||
| ArrayInput = Union[ArrowArrayExportable, BufferProtocolExportable, "np.ndarray"] |
Owner
There was a problem hiding this comment.
Since we use from __future__ import annotations above, we don't need to put this in a string
Suggested change
| ArrayInput = Union[ArrowArrayExportable, BufferProtocolExportable, "np.ndarray"] | |
| ArrayInput = Union[ArrowArrayExportable, BufferProtocolExportable, np.ndarray] |
Contributor
Author
There was a problem hiding this comment.
Yes I thought the same but actually you still need it for aliases, otherwise I get this
>>> from arro3.core.types import ArrowSchemaExportable
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/redab/tmp/venv/lib/python3.10/site-packages/arro3/core/types.py", line 82, in <module>
ArrayInput = Union[ArrowArrayExportable, BufferProtocolExportable, np.ndarray]
NameError: name 'np' is not defined
Owner
There was a problem hiding this comment.
Ugh damn it 😆, well TIL, sorry for messing up your PR!
We should really have some minimal CI tests to ensure that the library can at least import without any external dependencies.
Owner
|
This is the second error I made in the same file 😅 #207 |
This was referenced May 31, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
By building from source or installing the most recent pre-release on an empty virtual environment.
Actually importing
numpymay not be needed and we can get by with just aif TYPE_CHECKINGcondition and a forward reference.