Skip to content

fix: keep plot_ate axes as a list so the panels type-check - #1146

Open
anevolbap wants to merge 1 commit into
chore/mypy-gatefrom
chore/mypy-ipw-axes
Open

fix: keep plot_ate axes as a list so the panels type-check#1146
anevolbap wants to merge 1 commit into
chore/mypy-gatefrom
chore/mypy-ipw-axes

Conversation

@anevolbap

Copy link
Copy Markdown
Collaborator

Stacked on #1145. First allowlist entry to shrink.

plot_ate called plt.subplot_mosaic, which returns dict[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 positional axs[0], axs[1] and axs[2] was an index error and the declared tuple[Figure, list[Axes]] return was a return-value error. 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_weighting drops out of its dedicated [[tool.mypy.overrides]] entry and joins the plain arg-type group, which is the two remaining errors where fit is called with numpy arrays against a DataArray annotation. Those are the public-signature question and are left alone here.

Branch total: 49 errors in 16 files becomes 30 in 16.

Verification

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.

@read-the-docs-community

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

Copy link
Copy Markdown

Documentation build overview

📚 causalpy | 🛠️ Build #34126161 | 📁 Comparing 38d2ef2 against latest (7e23946)

  🔍 Preview build  

302 files changed · + 30 added · ± 239 modified · - 33 deleted

+ Added

± Modified

- Deleted

@drbenvincent

Copy link
Copy Markdown
Collaborator

Automated triage

Recommendation: review:medium — no decision gate identified.

Why:

  • Fixes a variable-rebinding issue in plot_ate (2 files changed: the IPW module and pyproject.toml allowlist). Mechanical, no behavioural change.
  • 19 mypy errors resolved by keeping the plt.subplot_mosaic result under its own name and the list under the original variable.
  • All CI checks pass. Stacked on chore: make mypy a real gate with a per-module allowlist #1145; tests pass and integration test confirms isinstance(axs, list).

Review focus:

  1. Confirm the mosaic dict iteration order (A, B, C) matches the original panel ordering.
  2. Verify the remaining arg-type allowlist entry for IPW .fit() calls is correctly scoped.

Confidence: high

@anevolbap
anevolbap force-pushed the chore/mypy-ipw-axes branch from 3669e45 to b1b338b Compare August 10, 2026 11:40
@anevolbap
anevolbap force-pushed the chore/mypy-ipw-axes branch from b1b338b to b8c2268 Compare August 18, 2026 16:20
@codecov

codecov Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.15%. Comparing base (7f95809) to head (38d2ef2).

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.
📢 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.

`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
anevolbap force-pushed the chore/mypy-ipw-axes branch from b8c2268 to 38d2ef2 Compare August 18, 2026 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review:medium Contained change requiring focused human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants