Commit 559b466
Tighten filters.py per /simplify pass
Four small wins from the review agents' findings:
- Type ``chunked``'s decorator factory with a ``TypeVar`` bound to the
fetch-once signature. Replaces the three-line
``Callable[[Callable[[dict], tuple[DF, Response]]], Callable[...]]``
dance with ``Callable[[_FetchOnce], _FetchOnce]``. The wrapper's
``@functools.wraps`` already preserves the signature; the TypeVar
makes that explicit to type-checkers.
- Drop the pointless ``build_request=lambda **kw: _construct_api_requests(**kw)``
wrapper in ``utils.get_ogc_data`` — the function reference itself
matches the callable shape.
- Factor the shared ``(?!NOT\b)(?P<field>…)\s+(?P<negated>NOT\s+)?``
subpattern used by ``_IN_NUMERIC_RE`` and ``_BETWEEN_NUMERIC_RE``
into a single module-level ``_FIELD_NEGATED`` constant. The two
regexes now compose it rather than repeat it.
- Drop the dead ``if p`` filter in ``_effective_filter_budget``'s
encoding-ratio scan. ``_split_top_level_or`` already drops empties,
and ``filter_expr`` is non-empty at that call site (guarded by
``_is_chunkable``). Note the invariant in a one-line comment.
- Trim the module docstring's redundant "Exports" section — the two
public names (``FILTER_LANG``, ``chunked``) are self-evident at
the declarations.
All 176 non-live tests still pass. No behaviour change.
Skipped from the review (per agents' own guidance or false positives):
- Collapsing the three pitfall regex scans into one alternation —
different group shapes, different error-message branches; no perf
gain worth the complexity.
- Unifying ``_iter_or_boundaries`` quote tracking with the pitfall
check's mask — narrow duplication, only worth factoring if another
CQL helper appears.
- Moving test helpers to ``conftest.py`` — not actively duplicated
(waterdata_utils_test.py no longer has them).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 7002420 commit 559b466
2 files changed
Lines changed: 30 additions & 31 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
| 60 | + | |
| 61 | + | |
67 | 62 | | |
68 | 63 | | |
69 | 64 | | |
70 | 65 | | |
71 | 66 | | |
72 | 67 | | |
73 | 68 | | |
74 | | - | |
| 69 | + | |
75 | 70 | | |
76 | 71 | | |
77 | 72 | | |
| |||
139 | 134 | | |
140 | 135 | | |
141 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
142 | 145 | | |
143 | 146 | | |
144 | 147 | | |
| |||
155 | 158 | | |
156 | 159 | | |
157 | 160 | | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
| 161 | + | |
| 162 | + | |
164 | 163 | | |
165 | | - | |
| 164 | + | |
166 | 165 | | |
167 | 166 | | |
168 | 167 | | |
169 | | - | |
170 | | - | |
| 168 | + | |
171 | 169 | | |
172 | | - | |
173 | | - | |
| 170 | + | |
174 | 171 | | |
175 | 172 | | |
176 | 173 | | |
| |||
322 | 319 | | |
323 | 320 | | |
324 | 321 | | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
325 | 325 | | |
326 | | - | |
| 326 | + | |
327 | 327 | | |
328 | 328 | | |
329 | 329 | | |
| |||
445 | 445 | | |
446 | 446 | | |
447 | 447 | | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
454 | 455 | | |
455 | 456 | | |
456 | 457 | | |
| |||
480 | 481 | | |
481 | 482 | | |
482 | 483 | | |
483 | | - | |
484 | | - | |
485 | | - | |
| 484 | + | |
486 | 485 | | |
487 | 486 | | |
488 | 487 | | |
| |||
504 | 503 | | |
505 | 504 | | |
506 | 505 | | |
507 | | - | |
| 506 | + | |
508 | 507 | | |
509 | 508 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
845 | 845 | | |
846 | 846 | | |
847 | 847 | | |
848 | | - | |
| 848 | + | |
849 | 849 | | |
850 | 850 | | |
851 | 851 | | |
| |||
0 commit comments