Skip to content

Conversation

@Airwave1981
Copy link
Contributor

@Airwave1981 Airwave1981 commented Jan 18, 2026

ℹ️ Description

Fixes a crash when loading configs on Pydantic v2 by not forwarding the unsupported call-time argument extra to
BaseModel.model_validate().

  • Link to the related issue(s): Issue #
  • Motivation/context: After a git reset (and with Pydantic 2.x), running pdm run app publish / config loading fails
    with TypeError: BaseModel.model_validate() got an unexpected keyword argument 'extra'. The wrapper
    ContextualModel.model_validate() accepted extra and forwarded it, which is not supported in Pydantic v2. This PR
    keeps the argument for compatibility but ignores it and documents the behavior.

Changes Summary

  • Stop passing extra=... from ContextualModel.model_validate() to BaseModel.model_validate().
  • Add a short note in the docstring explaining that call-time extra is ignored on Pydantic v2.
  • No dependency/config changes.

⚙️ Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (adds new functionality without breaking existing usage)
  • Breaking change (changes that might break existing user setups, scripts, or configurations)

✅ Checklist

  • I have reviewed my changes to ensure they meet the project's standards.
  • I have tested my changes and ensured that all tests pass (pdm run test). (not run)
  • I have formatted the code (pdm run format). (not run)
  • I have verified that linting passes (pdm run lint). (not run)
  • I have updated documentation where necessary. (not needed)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under
the terms of your choice.

Summary by CodeRabbit

  • Documentation
    • Clarified behavior for parameter handling with Pydantic v2, noting the parameter is accepted for compatibility but ignored.
  • Bug Fixes
    • Preserved backward-compatible method signature while ensuring the ignored parameter no longer affects validation.

✏️ Tip: You can customize this high-level summary in your review settings.

@github-actions github-actions bot added the bug Something isn't working label Jan 18, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 18, 2026

📝 Walkthrough

Walkthrough

The ContextualModel.model_validate method no longer forwards the extra parameter to the base implementation. The parameter remains in the public signature for backward compatibility but is ignored; docstring updated to note Pydantic v2 does not support call-time extra.

Changes

Cohort / File(s) Summary
Pydantic backward compatibility adjustment
src/kleinanzeigen_bot/utils/pydantics.py
Stop forwarding extra to super().model_validate; accept but ignore extra (no-op capture). Update docstring to explain Pydantic v2 lacks call-time extra.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main fix: preventing the extra parameter from being forwarded to BaseModel.model_validate(), which directly addresses the core issue resolved in the PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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 and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/kleinanzeigen_bot/utils/pydantics.py (1)

29-30: Fix by_name parameter compatibility with supported Pydantic versions.

The by_name parameter was added in Pydantic v2.11, but the project supports pydantic>=2.0.0 (including versions 2.0–2.10). Passing by_name unconditionally to super().model_validate() on line 47 will raise a TypeError at runtime on any Pydantic version before 2.11.

The same issue applies to line 46 if by_alias was added after v2.0. Consider either:

  1. Requiring Pydantic ≥2.11 in pyproject.toml, or
  2. Adding version checks before passing these parameters

@codecov
Copy link

codecov bot commented Jan 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.58%. Comparing base (0146952) to head (1806d2d).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #772   +/-   ##
=======================================
  Coverage   88.58%   88.58%           
=======================================
  Files          20       20           
  Lines        2172     2173    +1     
  Branches      423      423           
=======================================
+ Hits         1924     1925    +1     
  Misses        120      120           
  Partials      128      128           
Flag Coverage Δ
integration-tests 30.18% <0.00%> (-0.02%) ⬇️
smoke-tests 32.21% <100.00%> (+0.03%) ⬆️
unit-tests 88.49% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/kleinanzeigen_bot/utils/pydantics.py 46.85% <100.00%> (+0.37%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0146952...1806d2d. Read the comment docs.

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

1cu added a commit that referenced this pull request Jan 18, 2026
## ℹ️ Description
Raise Pydantic version cause we use features that require at least
v2.11.

- Link to the related issue(s): PR #772

## 📋 Changes Summary

- Set min version to v2.11

### ⚙️ Type of Change
Select the type(s) of change(s) included in this pull request:
- [x] 🐞 Bug fix (non-breaking change which fixes an issue)

## ✅ Checklist
Before requesting a review, confirm the following:
- [x] I have reviewed my changes to ensure they meet the project's
standards.
- [x] I have tested my changes and ensured that all tests pass (`pdm run
test`).
- [x] I have formatted the code (`pdm run format`).
- [x] I have verified that linting passes (`pdm run lint`).
- [x] I have updated documentation where necessary.

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Chores**
  * Updated project dependencies to improve compatibility and stability.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@1cu 1cu merged commit a247308 into main Jan 18, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Development

Successfully merging this pull request may close these issues.

3 participants