Skip to content

Fix 'was removed in version None' message in deprecated / deprecated_arg - #9291

Open
eliem08 wants to merge 2 commits into
Project-MONAI:devfrom
eliem08:fix/deprecated-version-none
Open

eliem08 wants to merge 2 commits into
Project-MONAI:devfrom
eliem08:fix/deprecated-version-none

Conversation

@eliem08

@eliem08 eliem08 commented Nov 19, 2026

Copy link
Copy Markdown

Bare @deprecated() / @deprecated_arg() with no versions set treat the object as already removed and raise DeprecatedError claiming it "was removed in version None".

This makes the version phrase conditional on removed being set, so the bare case now says "was removed." while the versioned case still says "was removed in version ." — the same conditional-phrase pattern as #9197 for deprecated_arg_default.

Adds two message tests (test_except1_message, test_arg_except1_message) covering both the bare and versioned cases. No in-repo caller hits this today (all pass explicit versions); it bites downstream users who use the decorators without versions.

tests/utils/test_deprecated.py: 33 passed (31 existing + 2 new).

Signed-off-by: Ilyass Emssaad emssaadelias@gmail.com

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review.

Walkthrough

The deprecated and deprecated_arg decorators now omit the removal-version clause when removed is None. When a removal version is set, the messages include it. Tests cover both cases for each decorator.

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

Merge Risk: Minimal · up to 897d5

This change fixes the misleading "was removed in version None" error message for decorators with no version set. Versioned messages are unchanged, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the 'was removed in version None' message in deprecated and deprecated_arg. The raw summary and objectives confirm the change makes the version phrase conditional on r…
Description check Passed The description states the bug, the fix, the two added tests, and the test results. It follows the template's Description section, and the Types of changes section is filled in. The Fixes # line has n…
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.
Full details: Title check

Explanation

The title names the main change: the 'was removed in version None' message in deprecated and deprecated_arg. The raw summary and objectives confirm the change makes the version phrase conditional on removed being set. The title is specific and matches the changeset.

Full details: Description check

Explanation

The description states the bug, the fix, the two added tests, and the test results. It follows the template's Description section, and the Types of changes section is filled in. The Fixes # line has no issue number, and the checklist lacks ticks for the test and docstring items. Those gaps are minor, so the description is mostly complete.

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between a85d75e and 897d585.

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.

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