Fail the suite on causalml's own arg-order FutureWarning (#995) - #997
Merged
Conversation
The repo has no filterwarnings setting anywhere, so a FutureWarning raised during a test run is printed and the run stays green. Both internal positional-call defects in the #854 shim (#988, #989) were found by running the suite by hand with -W error::FutureWarning, and each was then pinned by a bespoke "does not warn" test. Coverage is by enumeration, so it only protects the paths someone thought to protect. Add a pytest ini filter that promotes this one warning to an error, which makes every test in the suite a detector. Scoped to the shim's message rather than to FutureWarning generally, so a warning from numpy, pandas or scikit-learn cannot fail the build on a dependency release. No workflow change is needed: every lane runs plain pytest, and pytest.warns installs its own filter, so the tests that assert the warning are unaffected. The new test asserts a positional call raises under the repo's own config. The filter selects by message, so editing the warning text in _arg_order.py would stop it matching while CI stayed green. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ras44
approved these changes
Aug 10, 2026
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.
Proposed changes
Closes #995.
The suite has no warnings-as-errors lane. There is no
filterwarningssetting inpyproject.toml,setup.cfg,tests/conftest.pyor any workflow, so aFutureWarningraised during a test run is printed and the run stays green.That matters for the #854 shim specifically. It ships in 0.18.0 and stays live through 0.19.0 and 0.20.0 before the flip in v1.0 — about nine months. Both internal-positional-call defects so far (#988, #989) were found by running the suite by hand with
-W error::FutureWarning, and each was then pinned by a bespoke "does not warn" test written after the fact. Coverage is therefore by enumeration: it protects the three paths someone thought to protect.This adds a
[tool.pytest.ini_options]section with one filter, so every test in the suite becomes a detector instead:Scoped to this one message, not to
FutureWarninggenerally. A blanketerror::FutureWarningwould also promote warnings from numpy, pandas and scikit-learn, and the build would go red on a dependency release that has nothing to do with this repo.No workflow change is needed — every lane runs plain
pytestwith no-coverride, so the ini filter applies to the source builds and the optional TF/torch/JAX lanes alike.pytest.warnsinstalls its own filter, so the tests that assert the warning are unaffected.Types of changes
What types of changes does your code introduce to CausalML?
Put an
xin the boxes that applyTest/CI only — no library code changes.
Checklist
Further comments
What this catches that the current tests do not
Injected a positional
self.get_prediction(X, p, treatment, y)intoSensitivitySelectionBias.causalsens— the same defect class as #989, on a path none of the three bespoke tests assert on — and rantests/test_sensitivity.pyboth ways:-c /dev/null)test_SensitivitySelectionBiastest_SensitivitySelectionBiasandtest_SensitivitySelectionBias_summary_atealready execute that line; they simply had no reason to assert on warnings. The filter turns them into regression tests for free.The test
test_arg_order_warning_is_an_error_under_the_repo_pytest_configasserts a positional call raises under the repo's own config. The filter matches by message, so editing the warning text in_arg_order.pywould silently stop it matching while CI stayed green — the failure mode this issue exists to prevent. Mutation-checked: with thefilterwarningsentry removed, the test fails withDID NOT RAISE <class 'FutureWarning'>.Verification
$?, not through a pipe). 445 is the previous 444 plus the one test added here.tests/test_fit_arg_order.py: 58 → 59 tests, all passing.causalforest.py:136turns the suite red, which is the acceptance criterion on CI: no warnings-as-errors lane, so the #854 deprecation shim is untested against regressions #995. Worth noting thattest_causal_forest_keyword_fit_does_not_warnalready catches that one on its own — the filter's contribution is the untested paths above, not the three already pinned.black --checkclean.Not included
The issue also floated a separate CI job as an alternative. A single ini entry covers local runs and every CI lane at once, so a second job would add surface without adding coverage.
🤖 Generated with Claude Code