Skip to content

Fail the suite on causalml's own arg-order FutureWarning (#995) - #997

Merged
jeongyoonlee merged 1 commit into
masterfrom
feature/995-futurewarning-error-lane
Aug 10, 2026
Merged

Fail the suite on causalml's own arg-order FutureWarning (#995)#997
jeongyoonlee merged 1 commit into
masterfrom
feature/995-futurewarning-error-lane

Conversation

@jeongyoonlee

Copy link
Copy Markdown
Collaborator

Proposed changes

Closes #995.

The suite has no warnings-as-errors lane. There is no filterwarnings setting in pyproject.toml, setup.cfg, tests/conftest.py or any workflow, so a FutureWarning raised 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:

filterwarnings = [
    'error:Passing .treatment. and/or .y. to \w+\(\) by position is deprecated:FutureWarning',
]

Scoped to this one message, not to FutureWarning generally. A blanket error::FutureWarning would 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 pytest with no -c override, so the ini filter applies to the source builds and the optional TF/torch/JAX lanes alike. pytest.warns installs 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 x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Test/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) into SensitivitySelectionBias.causalsens — the same defect class as #989, on a path none of the three bespoke tests assert on — and ran tests/test_sensitivity.py both ways:

config result
master today (-c /dev/null) 20 passed, exit 0 — warning printed, defect invisible
this PR 7 failed, 13 passed, exit 1 — incl. test_SensitivitySelectionBias

test_SensitivitySelectionBias and test_SensitivitySelectionBias_summary_ate already 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_config asserts a positional call raises under the repo's own config. The filter matches by message, so editing the warning text in _arg_order.py would silently stop it matching while CI stayed green — the failure mode this issue exists to prevent. Mutation-checked: with the filterwarnings entry removed, the test fails with DID NOT RAISE <class 'FutureWarning'>.

Verification

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

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>
@jeongyoonlee
jeongyoonlee merged commit 28abbfb into master Aug 10, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI: no warnings-as-errors lane, so the #854 deprecation shim is untested against regressions

2 participants