types: finish the mypy ratchet across experimental, models, and preprocessing - #177
Merged
shivamlalakiya merged 1 commit intoSep 6, 2026
Merged
Conversation
…ocessing Annotates the last 129 unannotated functions across the estimator surface (experimental/_uplift.py, all 9 models/*.py, all 12 preprocessing/*.py). `fit` returns a per-class TypeVar bound to the class rather than a string literal, so a subclass's fit no longer reports its parent's type; `__sklearn_tags__` returns sklearn's public Tags dataclass (scikit-learn>=1.6, the declared floor). With every subpackage covered, collapses `[[tool.mypy.overrides]]` into a top-level `disallow_untyped_defs = true`, so a newly-added unannotated function anywhere in philanthropy fails CI instead of quietly enlarging the backlog. Closes #166.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
philanthropy.experimental,philanthropy.models, andphilanthropy.preprocessing, the three subpackages issue Finish the mypy ratchet: annotate model_selection, experimental, cli, models, preprocessing #166 tracked as remaining.fitreturns a per-classTypeVarbound to the class instead of a string-literal forward ref, so a subclass'sfitno longer reports its parent's type.__sklearn_tags__returns sklearn's publicTagsdataclass (scikit-learn>=1.6, the declared floor).[[tool.mypy.overrides]]into a top-leveldisallow_untyped_defs = trueinpyproject.toml. Closes Finish the mypy ratchet: annotate model_selection, experimental, cli, models, preprocessing #166.### Typingentry updated in place (matching the pattern from types: annotate metrics, utils, inspection and visualisation, and start the mypy ratchet #167/types: annotate model_selection and extend the mypy ratchet #172/types: annotate cli.py and extend the mypy ratchet #173) rather than appended, since it's the same ongoing item reaching completion.No behavior change: every edit is a type annotation. Verified with
make ci,make riskcov, and the ratchet probe from #166 (appending an unannotated function now failsmypy, confirmed then reverted).This PR only covers the mypy-ratchet item. A pass over
plan.md(gitignored, not part of this diff) found that the rest of the JOSS-prep checklist's code-shaped items —make_donor_panel, the three CI-executed notebooks, the real-data docs page, the "which estimator" table, YAML issue forms, the coverage-badge link,pypi-smoke.yml— were already shipped in earlier PRs (#161, #162, #165, #167, #170, #172, #173). This is genuinely the last code-only item left in that list; everything else remaining is non-code (preprint, Discussion post, outreach).Test plan
python -m mypy philanthropy— success, no issues, 50 source filesphilanthropyfailsmypywithdisallow_untyped_defs; reverted after confirmingmake ci(flake8, mypy, doctests, full test suite) — greenmake riskcov— 97% branch coverage over the risk-tier subtree, above the 93% floor