fix: keep plot_ate axes as a list so the panels type-check - #1146
Open
anevolbap wants to merge 1 commit into
Open
fix: keep plot_ate axes as a list so the panels type-check#1146anevolbap wants to merge 1 commit into
anevolbap wants to merge 1 commit into
Conversation
Collaborator
Automated triageRecommendation: Why:
Review focus:
Confidence: high |
anevolbap
force-pushed
the
chore/mypy-ipw-axes
branch
from
August 10, 2026 11:40
3669e45 to
b1b338b
Compare
anevolbap
force-pushed
the
chore/mypy-ipw-axes
branch
from
August 18, 2026 16:20
b1b338b to
b8c2268
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## chore/mypy-gate #1146 +/- ##
================================================
Coverage 97.15% 97.15%
================================================
Files 123 123
Lines 21744 21744
Branches 1177 1177
================================================
Hits 21125 21125
Misses 411 411
Partials 208 208 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
`plt.subplot_mosaic` returns `dict[str, Axes]`, and `plot_ate` rebound the same name to a list of the panels on the next line. mypy keeps the dict type for the rest of the function, so every positional `axs[0]`, `axs[1]` and `axs[2]` was an `index` error and the `tuple[Figure, list[Axes]]` return was a `return-value` error: 19 of the 49 errors on this branch, from one rebinding. The mosaic result now keeps its own name and the list gets the old one, so the positional uses and the declared return type agree. Iteration order over the mosaic dict is insertion order, A then B then C, exactly as before, so the panels keep their meaning and nothing renders differently. `inverse_propensity_weighting` therefore drops out of its dedicated allowlist entry and joins the plain `arg-type` group, which is the 2 remaining errors at line 138 where `fit` is called with numpy arrays against a `DataArray` annotation. Branch total goes from 49 errors in 16 files to 30 in 16.
anevolbap
force-pushed
the
chore/mypy-ipw-axes
branch
from
August 18, 2026 19:00
b8c2268 to
38d2ef2
Compare
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.
Stacked on #1145. First allowlist entry to shrink.
plot_atecalledplt.subplot_mosaic, which returnsdict[str, Axes], then rebound the same name to a list of the panels on the next line. mypy keeps the dict type for the rest of the function, so every positionalaxs[0],axs[1]andaxs[2]was anindexerror and the declaredtuple[Figure, list[Axes]]return was areturn-valueerror. That single rebinding accounted for 19 of the 49 errors on the base branch.The mosaic result now keeps its own name and the list takes the old one. Iteration over the mosaic dict is insertion order, A then B then C, exactly as before, so the panels keep their meaning and nothing renders differently.
inverse_propensity_weightingdrops out of its dedicated[[tool.mypy.overrides]]entry and joins the plainarg-typegroup, which is the two remaining errors wherefitis called with numpy arrays against aDataArrayannotation. Those are the public-signature question and are left alone here.Branch total: 49 errors in 16 files becomes 30 in 16.
Verification
mypygreen under--python-version 3.12and3.14.causalpy/tests/test_ipw_extreme_ps.pyandtest_ipw_get_ate.py: 39 passed. The first is theInversePropensityWeighting.plot_ate()fails with NaN error when propensity scores are extreme #645 regression suite and drivesplot_atefor every weighting scheme.test_integration_pymc_examples.py::test_inverse_proppassed; it assertsisinstance(axs, list)and that each element is anAxes, which is the contract this preserves.Being stacked on a feature branch, this gets the repo-wide workflows but not the test matrix. That arrives when #1145 merges and this retargets.