Skip to content

[refactor] update Pydantic mode='after' validator to instance method to fix deprecation warning#720

Open
Siddhazntx wants to merge 1 commit into
imDarshanGK:mainfrom
Siddhazntx:refactor/pydantic-model-validator
Open

[refactor] update Pydantic mode='after' validator to instance method to fix deprecation warning#720
Siddhazntx wants to merge 1 commit into
imDarshanGK:mainfrom
Siddhazntx:refactor/pydantic-model-validator

Conversation

@Siddhazntx
Copy link
Copy Markdown

Description

This PR resolves the PydanticDeprecatedSince212 warning triggered during the backend test suite execution.

In Pydantic V2.12+, using the @model_validator(mode="after") decorator on a @classmethod is deprecated. I have refactored the ensure_result_present validator in backend/app/schemas.py to be a standard instance method operating on self. This ensures full compatibility with Pydantic V2 and keeps the test summary output completely clean of internal code warnings.

Related Issue

Fixes #719

Type of change

  • Bug fix
  • New feature / enhancement
  • Documentation update
  • Test addition
  • Refactor

Checklist

  • I have read CONTRIBUTING.md
  • My branch is up to date with main
  • I have run pytest -v and all tests pass
  • I have not introduced duplicate issues or features
  • My PR title follows the format: feat/fix/docs/test: short description
  • I have added tests for new features (Level 2 and 3 issues)
  • No hardcoded secrets or API keys in my code
  • This PR is linked to a GSSoC 2026 issue

Screenshots (if frontend change)

N/A — backend logic refactoring only.

Test evidence

pytest -v

# ... [Test output omitted for brevity] ...
tests/test_zip_dos.py::test_analyze_zip_too_large_via_header PASSED                                                         [ 99%]
tests/test_zip_dos.py::test_analyze_zip_too_large_via_stream PASSED                                                         [ 99%]
tests/test_zip_dos.py::test_analyze_zip_valid PASSED                                                                        [100%]

========================================================= warnings summary =========================================================
aidevenv\Lib\site-packages\fastapi\testclient.py:1
  D:\AI-dev-assistant\backend\aidevenv\Lib\site-packages\fastapi\testclient.py:1: StarletteDeprecationWarning: Using `httpx` with `starlette.testclient` is deprecated; install `httpx2` instead.
    from starlette.testclient import TestClient as TestClient  # noqa

-- Docs: [https://docs.pytest.org/en/stable/how-to/capture-warnings.html](https://docs.pytest.org/en/stable/how-to/capture-warnings.html)
================================================== 367 passed, 1 warning in 9.20s ==================================================

@Siddhazntx Siddhazntx marked this pull request as ready for review May 31, 2026 05:46
@Siddhazntx Siddhazntx requested a review from imDarshanGK as a code owner May 31, 2026 05:46
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.

[Fix] Pydantic V2 deprecation warning in ShareCreateRequest validator

1 participant