Commit bdc8292
Introduce ConleyMetric type alias; fix public conley_metric signature
Address P2 Code Quality finding from CI Codex review of PR #411 on
0500909. Public signatures advertised `conley_metric: str` but the
runtime + docs + tests + REGISTRY all accept a callable
`(coords1, coords2) -> n×n` for custom (e.g. network) distance metrics.
Static type checkers and IDE autocomplete were therefore lying about the
public API contract.
Introduce a shared `ConleyMetric` type alias in `diff_diff/conley.py`:
ConleyMetric = Union[
Literal["haversine", "euclidean"],
Callable[[np.ndarray, np.ndarray], np.ndarray],
]
Sweep all 11 public/internal annotation sites:
- `solve_ols` overloads (4) + impl (1)
- `_solve_ols_numpy` overloads (4) + impl (1)
- `compute_robust_vcov`
- `_compute_robust_vcov_numpy`
- `LinearRegression.__init__`
Internal helpers in `conley.py` (`_pairwise_distance_matrix`,
`_validate_conley_kwargs`, `_compute_conley_vcov`) also annotated.
Moved the `from diff_diff.conley import ...` from late-file (line ~1192
with `noqa: E402`) to top-of-module so the `ConleyMetric` name is in
scope for the early function signatures (linalg.py has no
`from __future__ import annotations`, so types evaluate eagerly).
Verified locally: 72 Conley tests pass, ruff clean, sphinx -W exits 0.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 0500909 commit bdc8292
3 files changed
Lines changed: 40 additions & 20 deletions
File tree
- diff_diff
- docs/api/_autosummary
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
29 | 41 | | |
30 | 42 | | |
31 | 43 | | |
| |||
63 | 75 | | |
64 | 76 | | |
65 | 77 | | |
66 | | - | |
| 78 | + | |
67 | 79 | | |
68 | 80 | | |
69 | 81 | | |
| |||
116 | 128 | | |
117 | 129 | | |
118 | 130 | | |
119 | | - | |
| 131 | + | |
120 | 132 | | |
121 | 133 | | |
122 | 134 | | |
| |||
197 | 209 | | |
198 | 210 | | |
199 | 211 | | |
200 | | - | |
| 212 | + | |
201 | 213 | | |
202 | 214 | | |
203 | 215 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
52 | 62 | | |
53 | 63 | | |
54 | 64 | | |
| |||
352 | 362 | | |
353 | 363 | | |
354 | 364 | | |
355 | | - | |
| 365 | + | |
356 | 366 | | |
357 | 367 | | |
358 | 368 | | |
| |||
374 | 384 | | |
375 | 385 | | |
376 | 386 | | |
377 | | - | |
| 387 | + | |
378 | 388 | | |
379 | 389 | | |
380 | 390 | | |
| |||
396 | 406 | | |
397 | 407 | | |
398 | 408 | | |
399 | | - | |
| 409 | + | |
400 | 410 | | |
401 | 411 | | |
402 | 412 | | |
| |||
454 | 464 | | |
455 | 465 | | |
456 | 466 | | |
457 | | - | |
| 467 | + | |
458 | 468 | | |
459 | 469 | | |
460 | 470 | | |
| |||
818 | 828 | | |
819 | 829 | | |
820 | 830 | | |
821 | | - | |
| 831 | + | |
822 | 832 | | |
823 | 833 | | |
824 | 834 | | |
| |||
838 | 848 | | |
839 | 849 | | |
840 | 850 | | |
841 | | - | |
| 851 | + | |
842 | 852 | | |
843 | 853 | | |
844 | 854 | | |
| |||
858 | 868 | | |
859 | 869 | | |
860 | 870 | | |
861 | | - | |
| 871 | + | |
862 | 872 | | |
863 | 873 | | |
864 | 874 | | |
| |||
880 | 890 | | |
881 | 891 | | |
882 | 892 | | |
883 | | - | |
| 893 | + | |
884 | 894 | | |
885 | 895 | | |
886 | 896 | | |
| |||
1175 | 1185 | | |
1176 | 1186 | | |
1177 | 1187 | | |
1178 | | - | |
1179 | | - | |
1180 | | - | |
1181 | | - | |
1182 | | - | |
| 1188 | + | |
| 1189 | + | |
1183 | 1190 | | |
1184 | 1191 | | |
1185 | 1192 | | |
| |||
1193 | 1200 | | |
1194 | 1201 | | |
1195 | 1202 | | |
1196 | | - | |
| 1203 | + | |
1197 | 1204 | | |
1198 | 1205 | | |
1199 | 1206 | | |
| |||
1640 | 1647 | | |
1641 | 1648 | | |
1642 | 1649 | | |
1643 | | - | |
| 1650 | + | |
1644 | 1651 | | |
1645 | 1652 | | |
1646 | 1653 | | |
| |||
2478 | 2485 | | |
2479 | 2486 | | |
2480 | 2487 | | |
2481 | | - | |
| 2488 | + | |
2482 | 2489 | | |
2483 | 2490 | | |
2484 | 2491 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
0 commit comments