Skip to content

fix: fix pydantic deprecation warning#269

Merged
tlambert03 merged 8 commits intopyapp-kit:mainfrom
tlambert03:fix-deprecation
Nov 9, 2025
Merged

fix: fix pydantic deprecation warning#269
tlambert03 merged 8 commits intopyapp-kit:mainfrom
tlambert03:fix-deprecation

Conversation

@tlambert03
Copy link
Copy Markdown
Member

@tlambert03 tlambert03 commented Nov 9, 2025

fixes #268

@codecov
Copy link
Copy Markdown

codecov bot commented Nov 9, 2025

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 99.62%. Comparing base (6a228ea) to head (f2bdc24).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/app_model/types/_keys/_keybindings.py 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #269      +/-   ##
==========================================
- Coverage   99.68%   99.62%   -0.06%     
==========================================
  Files          31       31              
  Lines        1877     1878       +1     
==========================================
  Hits         1871     1871              
- Misses          6        7       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

tlambert03 pushed a commit that referenced this pull request Nov 9, 2025
The Pydantic 2.12+ deprecation warning asks to convert @model_validator
with mode='after' from a classmethod to an instance method, NOT to change
from mode='after' to mode='before'.

The PR #269's approach of using mode='before' was incorrect and caused
issues with PySide because:
- mode='before' receives raw input before Pydantic processes it
- Returning an already-constructed instance from a 'before' validator
  interferes with Pydantic's validation flow
- This manifests differently with PySide vs PyQt due to Qt type handling

This fix:
- Keeps mode='after' as Pydantic recommends
- Changes from classmethod to instance method
- Simplifies the validator to a no-op (returns self)
- Fixes the PySide test failures
- Removes the deprecation warning

Fixes #268
@tlambert03 tlambert03 merged commit ec8e43d into pyapp-kit:main Nov 9, 2025
48 of 49 checks passed
@tlambert03 tlambert03 deleted the fix-deprecation branch November 9, 2025 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Pydantic 2.12+ compatibility

1 participant