Commit aeb0f0a
Simplify chunking module: shared helpers, idiomatic max(), tighter types
Five targeted cleanups from review, no behavior change:
- Drop the duplicate ``_FetchOnce`` TypeVar in chunking.py; import the
one already defined in filters.py. The two had identical bodies.
- Extract ``_max_per_clause_encoding_ratio(parts)`` in filters.py.
Both ``_effective_filter_budget`` and the outer
``_filter_aware_probe_args`` need the same worst-case ratio
formula; pinning it in one place keeps them from drifting.
- Replace the manual ``best: tuple | None`` sentinel + nested-loop
scan in ``_plan_chunks`` with a generator + ``max(..., key=...,
default=None)``. Removes the sentinel, the conditional-update
branch, and the post-loop ``if best is None`` check.
- Extract ``_finalize_paginated_response`` in utils.py so the
4-line "carry last page's headers + cumulative elapsed onto the
initial response" pattern lives in one spot instead of duplicated
across ``_walk_pages`` and the stats helper.
- Tighten parametrized type hints from ``dict[str, list]`` to
``dict[str, list[Any]]`` (and the planner's return type) per
PEP 585.
Also trimmed the 17-line ``_filter_aware_probe_args`` docstring to
9 lines; the substance is preserved, the prose is leaner.
All 209 waterdata tests pass; ruff clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 82087ad commit aeb0f0a
3 files changed
Lines changed: 66 additions & 55 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
| 54 | + | |
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
| |||
161 | 163 | | |
162 | 164 | | |
163 | 165 | | |
164 | | - | |
| 166 | + | |
165 | 167 | | |
166 | 168 | | |
167 | 169 | | |
| |||
173 | 175 | | |
174 | 176 | | |
175 | 177 | | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
194 | 188 | | |
195 | 189 | | |
196 | 190 | | |
| |||
199 | 193 | | |
200 | 194 | | |
201 | 195 | | |
202 | | - | |
203 | 196 | | |
204 | | - | |
| 197 | + | |
205 | 198 | | |
206 | 199 | | |
207 | 200 | | |
| |||
239 | 232 | | |
240 | 233 | | |
241 | 234 | | |
242 | | - | |
| 235 | + | |
243 | 236 | | |
244 | 237 | | |
245 | 238 | | |
| |||
255 | 248 | | |
256 | 249 | | |
257 | 250 | | |
258 | | - | |
| 251 | + | |
259 | 252 | | |
260 | 253 | | |
261 | 254 | | |
| |||
280 | 273 | | |
281 | 274 | | |
282 | 275 | | |
283 | | - | |
| 276 | + | |
284 | 277 | | |
285 | 278 | | |
286 | 279 | | |
287 | 280 | | |
288 | 281 | | |
289 | 282 | | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
301 | 292 | | |
302 | 293 | | |
303 | 294 | | |
304 | 295 | | |
305 | 296 | | |
306 | 297 | | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
311 | 301 | | |
312 | 302 | | |
313 | 303 | | |
| |||
323 | 313 | | |
324 | 314 | | |
325 | 315 | | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | 316 | | |
333 | 317 | | |
334 | 318 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
155 | 167 | | |
156 | 168 | | |
157 | 169 | | |
| |||
163 | 175 | | |
164 | 176 | | |
165 | 177 | | |
166 | | - | |
167 | | - | |
| 178 | + | |
168 | 179 | | |
169 | 180 | | |
170 | 181 | | |
| |||
179 | 190 | | |
180 | 191 | | |
181 | 192 | | |
182 | | - | |
| 193 | + | |
183 | 194 | | |
184 | 195 | | |
185 | 196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
618 | 618 | | |
619 | 619 | | |
620 | 620 | | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
621 | 641 | | |
622 | 642 | | |
623 | 643 | | |
| |||
703 | 723 | | |
704 | 724 | | |
705 | 725 | | |
706 | | - | |
707 | | - | |
708 | | - | |
| 726 | + | |
709 | 727 | | |
710 | 728 | | |
711 | 729 | | |
| |||
1180 | 1198 | | |
1181 | 1199 | | |
1182 | 1200 | | |
1183 | | - | |
1184 | | - | |
1185 | | - | |
| 1201 | + | |
1186 | 1202 | | |
1187 | 1203 | | |
1188 | 1204 | | |
| |||
0 commit comments