Commit c027609
committed
Drop Python 2/3 compatibility shim from util.py
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>1 parent ad9d26c commit c027609
1 file changed
Lines changed: 19 additions & 39 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | 31 | | |
43 | 32 | | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
| 33 | + | |
54 | 34 | | |
55 | 35 | | |
56 | 36 | | |
57 | 37 | | |
58 | 38 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 39 | + | |
63 | 40 | | |
64 | 41 | | |
65 | 42 | | |
| |||
75 | 52 | | |
76 | 53 | | |
77 | 54 | | |
78 | | - | |
| 55 | + | |
79 | 56 | | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
84 | 61 | | |
85 | 62 | | |
86 | 63 | | |
| |||
90 | 67 | | |
91 | 68 | | |
92 | 69 | | |
93 | | - | |
94 | | - | |
95 | | - | |
| 70 | + | |
96 | 71 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
101 | 81 | | |
102 | 82 | | |
103 | 83 | | |
| |||
0 commit comments