Skip to content

fix: clear the stale type: ignore comments and gate warn_unused_ignores - #1172

Open
anevolbap wants to merge 2 commits into
chore/mypy-zerofrom
chore/mypy-zero-cleanup
Open

fix: clear the stale type: ignore comments and gate warn_unused_ignores#1172
anevolbap wants to merge 2 commits into
chore/mypy-zerofrom
chore/mypy-zero-cleanup

Conversation

@anevolbap

@anevolbap anevolbap commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Branched on top of #1173, which is itself stacked on #1149. Clears the 33 unused type: ignore comments that #1149 left as a follow-up, and turns warn_unused_ignores on.

The base field still reads chore/mypy-zero because 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 into chore/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.py carried type: ignore[call-arg,union-attr] and mypy flagged only union-attr, so this PR originally narrowed it to [call-arg]. #1173 narrows self.model to 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_ignores on 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.
  • Full suite: 2294 passed, 18 skipped, 3 deselected.
  • prek run --all-files clean.

Stacked on a feature branch, so the test matrix only arrives once the stack merges down.

@read-the-docs-community

read-the-docs-community Bot commented Aug 19, 2026

Copy link
Copy Markdown

Documentation build overview

📚 causalpy | 🛠️ Build #34129954 | 📁 Comparing 8fa0517 against latest (ea44a98)

  🔍 Preview build  

280 files changed · + 30 added · ± 228 modified · - 22 deleted

+ Added

± Modified

- Deleted

…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.
@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.87500% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 97.15%. Comparing base (aa2ae59) to head (8fa0517).
⚠️ Report is 1 commits behind head on chore/mypy-zero.

Files with missing lines Patch % Lines
causalpy/pymc_models.py 0.00% 0 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@anevolbap
anevolbap marked this pull request as ready for review August 19, 2026 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant