Skip to content

Fix deprecated_arg_default message for an already-changed default - #9197

Open
eliem08 wants to merge 1 commit into
Project-MONAI:devfrom
eliem08:fix/deprecated-arg-default-message
Open

eliem08 wants to merge 1 commit into
Project-MONAI:devfrom
eliem08:fix/deprecated-arg-default-message

Conversation

@eliem08

@eliem08 eliem08 commented Oct 20, 2026

Copy link
Copy Markdown

Description

Since #8473 (1.5.1), Orientation and Orientationd warn on every construction that doesn't pass labels:

Current default value of argument `labels=(('L', 'R'), ('P', 'A'), ('I', 'S'))` was changed in version None from `labels=(('L', 'R'), ('P', 'A'), ('I', 'S'))` to `labels=None`.

The decorator is declared without since/replaced, so deprecated_arg_default prints version None, and the "Current default value of argument labels=(('L', 'R'), ...)" prefix suggests the old default is still in effect.

Setting replaced="1.5.1" on the decorators is not a safe fix: when the MONAI version is unknown (0+..., e.g. a source checkout without tags), is_replaced is False, the signature default already equals new_default, and the decorator raises ValueError at import time.

This PR changes only the message for a replaced default:

Default value of argument `labels` was changed from `labels=(('L', 'R'), ('P', 'A'), ('I', 'S'))` to `labels=None`. ...

and includes in version X when replaced is given. Which warnings fire, and when, is unchanged. The stale "raise a DeprecatedError directly" comment is replaced, since that branch only warns.

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • New tests added to cover the changes.

Tests

  • New test_deprecated_arg_default_replaced_message checks the wording with and without a version.
  • tests/utils/test_deprecated.py, tests/transforms/test_orientation.py and test_orientationd.py: 99 passed (98 before plus the new test). The 2 pytest errors on test_orientationd.py (test_resampler_lazy collected as a test, fixture resampler not found) also occur on unmodified dev.
  • black --check and ruff check pass on the changed files.

Orientation(d) declares the labels default change from Project-MONAI#8473 without since
or replaced, so the FutureWarning read "was changed in version None" and
began "Current default value of argument labels=(('L', 'R'), ...)", which
suggests the old default is still in effect. Setting replaced is not an
option: with an unknown MONAI version (e.g. a source checkout without tags)
the signature check raises at import time.

For a replaced default, word the message as "Default value of argument X
was changed [in version V] from ... to ...", omitting the version when it
is not given.

Signed-off-by: eliem08 <emssaadelias@gmail.com>
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: Project-MONAI/MONAI/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b55f841d-bf4a-4bd3-8237-13c8a99dbc1c
📥 Commits

Reviewing files that changed from the base of the PR and between d820099 and 57dca89.

📒 Files selected for processing: 2
  • monai/utils/deprecate_utils.py
  • tests/utils/test_deprecated.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📝 Walkthrough

deprecated_arg_default now reports the default transition when no version is provided. Its replacement warning identifies the argument’s default, reports the old and new values, and includes the replacement version when available. Tests cover both message cases.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 57dca

No identified issue prevents merging the warning-message update after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change to the deprecated_arg_default message.
Description check Passed The description explains the issue, implementation, behavior impact, tests, and validation results. The empty issue reference and unchecked optional test and documentation items do not prevent review.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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