Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support upcoming changes in Pydantic version 2.10. #1214

Closed
wants to merge 1 commit into from

Conversation

mtr
Copy link

@mtr mtr commented Nov 15, 2024

Without this fix, any SQLModel-based model with table=True and a Field that sets default_factory=... will brake with the following error message: ValueError: 'validated_data' must be provided if 'call_default_factory' is True.

To reproduce, before this fix is applied:

  • Install all project dependencies, then upgrade Pydantic:

    pip install -r requirements.txt
    pip install pydantic==2.10.0b2
  • Run the test suite:

    python -m pytest tests

… which will give the following output:

[…]
=================================================================== short test summary info ====================================================================
FAILED tests/test_annotated_uuid.py::test_annotated_optional_types - ValueError: 'validated_data' must be provided if 'call_default_factory' is True.
FAILED tests/test_advanced/test_uuid/test_tutorial001.py::test_tutorial - ValueError: 'validated_data' must be provided if 'call_default_factory' is True.
FAILED tests/test_advanced/test_uuid/test_tutorial001_py310.py::test_tutorial - ValueError: 'validated_data' must be provided if 'call_default_factory' is True.
FAILED tests/test_advanced/test_uuid/test_tutorial002.py::test_tutorial - ValueError: 'validated_data' must be provided if 'call_default_factory' is True.
FAILED tests/test_advanced/test_uuid/test_tutorial002_py310.py::test_tutorial - ValueError: 'validated_data' must be provided if 'call_default_factory' is True.
===================================================== 5 failed, 250 passed, 3 skipped, 7 warnings in 9.37s =====================================================

Without this fix, any SQLModel-based model with `table=True` and a `Field` that sets `default_factory=...` will brake with the following error message: `ValueError: 'validated_data' must be provided if 'call_default_factory' is True.`
@mtr
Copy link
Author

mtr commented Nov 15, 2024

I broke the test when running with non-upgraded Pydantic. I will create a new pull-request once it is fixed.

@mtr mtr closed this Nov 15, 2024
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