← Back to Pull requests

[18.0][FIX] fs_storage: scope the warnings filter set by @deprecated #701

Closed
unknown closed this pull request without merging on Dec 01, 2026 09:54 UTC
View on GitHub
unknown unknown commented on Nov 24, 2026 22:21 UTC
Author

Problem

The @deprecated decorator in fs_storage/models/fs_storage.py calls warnings.simplefilter("always", DeprecationWarning) and then warnings.simplefilter("default", DeprecationWarning) outside of warnings.catch_warnings(). Each call to a deprecated fs.storage method (add, get, list_files, find_files, move_files, delete) therefore inserts a global DeprecationWarning rule at the front of the process-wide filter list.

That rule takes precedence over the filters Odoo installs in odoo/netsvc.py, for example the ignore rule for datetime.datetime.utcnow() is deprecated. Once the test_deprecated_* tests of fs_storage have run (they are at_install, so they run early), unrelated tests later in the same build start logging warnings such as:

WARNING ... py.warnings: .../addons/mail/models/mail_activity_mixin.py:294: DeprecationWarning: datetime.datetime.utcnow() is deprecated ...

The test helpers _test_deprecated_setting_and_getting_data and _test_deprecated_find_files also call warnings.filterwarnings("ignore") globally, which silences every warning for the rest of the process.

Fix

  • Wrap the simplefilter("always", ...) + warn() of the decorator in warnings.catch_warnings(), so the filter only applies to that call. The DeprecationWarning is still emitted.

  • Remove the global warnings.filterwarnings("ignore") from the test helpers. They are already decorated with mute_logger("py.warnings").

  • Add a regression test, test_deprecated_decorator_restores_warning_filters, which checks that warnings.filters is unchanged after calling a deprecated method and that the DeprecationWarning is still raised.
  • Tests

    -i fs_storage --test-tags /fs_storage with demo data:

  • Without the decorator fix: 1 failed ... of 20 tests (the new regression test).

  • With the fix: 0 failed, 0 error(s) of 20 tests, no WARNING/ERROR lines in the log.
  • The same decorator exists on 17.0 and 19.0; this can be forward-ported once merged.

    Diff: 253 lines (+189 / -64) across 3 files Reviewer: lmignon Review duration: 9332m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 253 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.331
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #701"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.1% (MEDIUM) · Higher = larger blast radius
    39.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.4% · Safe to merge
    15.4%
    Repository