Repository navigation
Commit 3c11ff6
tests: type the split-token tests against the real production types
The mypy gate on tests/ was added in 0.26.0 with tests/ clean, but a run of
commits then landed without CI ever executing, so 21 errors accumulated
unseen. They are not one mistake repeated; they are three, and each one is
the test having drifted from production rather than production being wrong.
Structural stand-ins for nominal types. test_split_token.py built a local
_Auth class with the three attributes _identity_tail reads, and a local _Ctx
with a bare `auth = None`. Both work at runtime because Python does not
check, but AuthContext and CallContext are nominal types with real
constructors, and every other test in the tree (test_worker, test_auth,
test_aggregate_function) already builds them directly. Replaced with
AuthContext(domain=..., authenticated=True, principal=...) and the
`CallContext(auth=AuthContext.anonymous(), ...)` idiom the rest of the suite
uses. Behaviourally identical: _identity_tail maps both `None` and an
unauthenticated context to the same anonymous tail.
Borrowing an unbound method instead of inheriting it. Three test-local
worker doubles did `_stamp_split_tokens = Worker._stamp_split_tokens` on a
class that was not a Worker, which mypy correctly flags as an invalid self
argument -- the double satisfied the method's needs by accident, and would
keep compiling if _stamp_split_tokens grew a dependency on any other Worker
member. They are now Worker subclasses overriding _current_split_anchor,
which is the seam the method actually documents. Worker is constructible
with no arguments, so this costs nothing.
Wire types passed as their serialized shape. `arguments=b""` and
`function_type="TABLE"` are what those fields become on the wire, not what
BindRequest declares (Arguments and the FunctionType enum). Every other
BindRequest in the suite already passes the declared types; these three were
written before anything checked.
Also narrowed PlanResponse.splits at its two use sites. It is genuinely
`list[ScanSplit] | list[bytes]` because a worker may hand back either, but
stamping always returns the serialized form -- so the new _stamped() helper
asserts that rather than casting it away, which pins that half of the
contract while it narrows.
One unrelated error in test_wire_record_schema_parity.py: a bare pa.Scalar
where strict mode wants pa.Scalar[Any], matching how vgi/arguments.py spells
it.
No production code changed; no type was loosened and no ignore was added.
`mypy vgi/`, `mypy tests/`, ruff format/check, and the full suite (2438
passed) are all green.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent cdb50d0 commit 3c11ff6
2 files changed
Lines changed: 47 additions & 52 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
| 15 | + | |
14 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
15 | 20 | | |
16 | 21 | | |
17 | 22 | | |
| |||
33 | 38 | | |
34 | 39 | | |
35 | 40 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
41 | 62 | | |
42 | 63 | | |
43 | 64 | | |
| |||
105 | 126 | | |
106 | 127 | | |
107 | 128 | | |
108 | | - | |
| 129 | + | |
109 | 130 | | |
110 | | - | |
| 131 | + | |
111 | 132 | | |
112 | | - | |
| 133 | + | |
113 | 134 | | |
114 | 135 | | |
115 | 136 | | |
| |||
156 | 177 | | |
157 | 178 | | |
158 | 179 | | |
159 | | - | |
| 180 | + | |
160 | 181 | | |
161 | 182 | | |
162 | 183 | | |
| |||
224 | 245 | | |
225 | 246 | | |
226 | 247 | | |
227 | | - | |
228 | | - | |
229 | 248 | | |
230 | | - | |
| 249 | + | |
231 | 250 | | |
232 | 251 | | |
233 | | - | |
234 | | - | |
235 | | - | |
| 252 | + | |
236 | 253 | | |
237 | 254 | | |
238 | | - | |
239 | | - | |
240 | | - | |
| 255 | + | |
241 | 256 | | |
242 | 257 | | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | 258 | | |
247 | 259 | | |
248 | 260 | | |
249 | | - | |
| 261 | + | |
250 | 262 | | |
251 | | - | |
| 263 | + | |
252 | 264 | | |
253 | 265 | | |
254 | 266 | | |
| |||
260 | 272 | | |
261 | 273 | | |
262 | 274 | | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | 275 | | |
269 | | - | |
| 276 | + | |
| 277 | + | |
270 | 278 | | |
271 | 279 | | |
272 | | - | |
273 | | - | |
274 | | - | |
| 280 | + | |
275 | 281 | | |
276 | 282 | | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | 283 | | |
281 | | - | |
282 | | - | |
| 284 | + | |
| 285 | + | |
283 | 286 | | |
284 | 287 | | |
285 | 288 | | |
| |||
310 | 313 | | |
311 | 314 | | |
312 | 315 | | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | 316 | | |
317 | 317 | | |
318 | | - | |
| 318 | + | |
319 | 319 | | |
320 | 320 | | |
321 | | - | |
| 321 | + | |
322 | 322 | | |
323 | 323 | | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
| 324 | + | |
330 | 325 | | |
331 | | - | |
| 326 | + | |
332 | 327 | | |
333 | 328 | | |
334 | | - | |
| 329 | + | |
335 | 330 | | |
336 | 331 | | |
337 | 332 | | |
338 | | - | |
| 333 | + | |
339 | 334 | | |
340 | 335 | | |
341 | 336 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| |||
0 commit comments