Commit 29f6363
committed
fix: two runtime PEP 604 sites that FA102 structurally cannot catch
3.9 was the last red leg: 1 failed, 8 errors, 1712 passed. Same family as
17e7e6c, but a variant the linter cannot see - both files already carry
`from __future__ import annotations`, which is exactly why FA102 stays quiet
while the code still breaks at runtime.
backend.py `cast(CUDABatchDecoder | None, ...)`. The future import stringifies
annotations; an argument to `cast()` is an ordinary expression and is evaluated
on import, so `type.__or__` is reached on 3.9 and the package fails to import.
Quote the target - `cast` never evaluates its first argument, and type checkers
read string forward refs fine.
rest_api.py `n_qubits: int | None` on a pydantic BaseModel. Here the future
import actively hurts: the annotation arrives at pydantic as the string
"int | None", which it eval()s to resolve the model, and on 3.9 that raises.
It surfaced as six errors recommending `eval_type_backport`, plus two cascading
'NoneType' has no attribute '_rate_lock' errors once the module failed to load.
Use `Optional[int]`. The neighbouring `list[list[int]]` is left alone - PEP 585
builtin subscripting landed in 3.9; only PEP 604 unions did not.
Swept for the rest of this shape rather than fixing only what failed: these are
the only two `cast()` sites and the only pydantic field affected; no
isinstance/issubclass union arguments exist.
The real guard is the 3.9 leg itself, which now gets far enough to import every
module - it could not before 17e7e6c.1 parent b9425e0 commit 29f6363
2 files changed
Lines changed: 19 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
298 | 306 | | |
299 | | - | |
| 307 | + | |
300 | 308 | | |
301 | 309 | | |
302 | | - | |
| 310 | + | |
303 | 311 | | |
304 | 312 | | |
305 | 313 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
127 | 134 | | |
128 | 135 | | |
129 | 136 | | |
| |||
0 commit comments