Drop Python 2/3 compatibility shim from util.py - #122
Merged
Conversation
Replace the version_info-gated import of subprocess.check_output /
getoutput (and the py3 / spop / branched fpath usage) with a direct
import of subprocess.getoutput. Also defines fpath unconditionally at
module level so the manylinux1 fallback no longer references an
undefined name on macOS/Windows.
Gate numpy .astype path with isinstance check in _FFIArray
The duck-typed try/except (TypeError, AttributeError) around
seq.astype(np.float64) caught two distinct conditions:
1. numpy arrays whose buffer wasn't writable (TypeError from
from_buffer) -- handled by retrying with from_buffer_copy.
2. array.array / list / tuple inputs that lack .astype entirely
(AttributeError) -- handled by falling through to
array_type.from_buffer(array("d", seq)).
Make the numpy vs non-numpy branch explicit with isinstance(seq,
np.ndarray) so the .astype call lives on a known-numpy path. Resolves
the ty 'possibly-missing-attribute' diagnostic on .astype without
changing runtime behaviour for any input type.
The two .astype calls carry # ty: ignore[no-matching-overload]
because ty's current numpy stubs can't unify any dtype argument form
(np.float64, "float64", np.dtype(...)) against the overloaded
signature -- a stubs limitation rather than a real type error.
Signed-off-by: Stephan Hügel <shugel@tcd.ie>
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.
Replace the version_info-gated import of subprocess.check_output / getoutput (and the py3 / spop / branched fpath usage) with a direct import of subprocess.getoutput. Also defines fpath unconditionally at module level so the manylinux1 fallback no longer references an undefined name on macOS/Windows.
Gate numpy .astype path with isinstance check in _FFIArray
The duck-typed try/except (TypeError, AttributeError) around seq.astype(np.float64) caught two distinct conditions:
Make the numpy vs non-numpy branch explicit with isinstance(seq, np.ndarray) so the .astype call lives on a known-numpy path. Resolves the ty 'possibly-missing-attribute' diagnostic on .astype without changing runtime behaviour for any input type.
The two .astype calls carry # ty: ignore[no-matching-overload] because ty's current numpy stubs can't unify any dtype argument form (np.float64, "float64", np.dtype(...)) against the overloaded signature -- a stubs limitation rather than a real type error.