fix: clear the stale type: ignore comments and gate warn_unused_ignores - #1172
Open
anevolbap wants to merge 2 commits into
Open
fix: clear the stale type: ignore comments and gate warn_unused_ignores#1172anevolbap wants to merge 2 commits into
anevolbap wants to merge 2 commits into
Conversation
…eighting Both experiments require a specific PyMCModel subclass with a non-standard fit() signature (InstrumentalVariableRegression, PropensityScore), but self.model was typed as the full BaseExperiment model union, so the fit call sites needed type: ignore comments. Declare model: InstrumentalVariableRegression / model: PropensityScore on each subclass. Both already restrict their constructor's model parameter and _default_model_class to that type, so this states statically what was already true at runtime and lets mypy resolve fit() against the concrete subclass instead of the union. BaseExperiment.model is unchanged, so this does not affect any other experiment or the public model attribute.
33 line-level ignores across 10 modules no longer suppress anything, per mypy --warn-unused-ignores in both the CausalPy and CausalPy-pymc6 envs (identical unused set in both). Deleted them; narrowed the one partially unused case in instrumental_variable.py to the code still needed (call-arg, not union-attr). warn_unused_ignores is now on in [tool.mypy] so a future fix that drops the underlying error also has to drop its now-stale ignore.
anevolbap
force-pushed
the
chore/mypy-zero-cleanup
branch
from
August 19, 2026 01:48
0c90170 to
8fa0517
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## chore/mypy-zero #1172 +/- ##
================================================
Coverage 97.15% 97.15%
================================================
Files 123 123
Lines 21747 21749 +2
Branches 1177 1177
================================================
+ Hits 21128 21131 +3
Misses 411 411
+ Partials 208 207 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
anevolbap
marked this pull request as ready for review
August 19, 2026 02:06
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.
Branched on top of #1173, which is itself stacked on #1149. Clears the 33 unused
type: ignorecomments that #1149 left as a follow-up, and turnswarn_unused_ignoreson.The base field still reads
chore/mypy-zerobecause GitHub refuses to retarget a PR that is part of a stack, so the diff currently shows #1173's commit as well. That resolves itself: once #1173 merges intochore/mypy-zero, this PR narrows to its own single commit. Merge #1173 first.All 33 carried explicit error codes, none bare, so removing them can't unmask a hidden error class.
CausalPy and CausalPy-pymc6 resolve different numpy and matplotlib stubs, so I checked both before deleting anything: same 33 lines, same 10 files, in both. Nothing needed to stay for one env only.
No source behaviour changes. Every deletion is a clean unused-ignore removal.
Why it sits on #1173 rather than #1149
One of the 33 was only partly unused:
instrumental_variable.pycarriedtype: ignore[call-arg,union-attr]and mypy flagged onlyunion-attr, so this PR originally narrowed it to[call-arg]. #1173 narrowsself.modelto the concrete subclass, which removes that ignore and its neighbours entirely, so the two PRs were editing the same line in incompatible ways. Rebasing onto #1173 drops that hunk from this PR: it now touches 10 files instead of 11, and the remaining 32 deletions are independent of it.The dependency runs the other way too, which is why these cannot be siblings. Turning
warn_unused_ignoreson requires that line to already be clean, and only #1173 makes it clean.Verification
mypy==2.3.0 --warn-unused-ignores:Success: no issues found in 54 source files, in both envs, after the rebase.2294 passed, 18 skipped, 3 deselected.prek run --all-filesclean.Stacked on a feature branch, so the test matrix only arrives once the stack merges down.