Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

cjwatson
Copy link

@cjwatson cjwatson commented Sep 2, 2025

tests/test_multi_body_errors.py::test_openapi_schema failed with pydantic 2.12.0a1 due to
pydantic/pydantic#11987. Since we're testing the exact contents of the JSON schema, the easiest fix seems to be to add version-dependent handling for this.

@YuriiMotov
Copy link
Contributor

I think we should try to avoid adding new dependency.

Maybe something with dirty_equals?
Take a look at the code in the details

from dirty_equals import IsOneOf

v1 = {
    "age": {
        "title": "Age",
        "anyOf": [
            {"exclusiveMinimum": 0.0, "type": "number"},
            {"type": "string"},
        ],
    }
}

v2 = {
    "age": {
        "title": "Age",
        "anyOf": [
            {"exclusiveMinimum": 0.0, "type": "number"},
            {"type": "string", "pattern": r"^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$"},
        ],
    }
}


expected = {
    "age": {
        "title": "Age",
        "anyOf": [
            {"exclusiveMinimum": 0.0, "type": "number"},
            IsOneOf(
                {"type": "string"},
                {"type": "string", "pattern": r"^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$"}
            ),
        ],
    }
}

assert v1 == expected
assert v2 == expected

@svlandeg svlandeg changed the title Prepare for pydantic 2.12.0 👽️ Ensure compatibility with Pydantic 2.12.0 Sep 3, 2025
@svlandeg svlandeg added upgrade and removed internal labels Sep 3, 2025
@cjwatson
Copy link
Author

cjwatson commented Sep 7, 2025

I think we should try to avoid adding new dependency.

Maybe something with dirty_equals? Take a look at the code in the details

Ah yes, that works too, thanks. Amended.

`tests/test_multi_body_errors.py::test_openapi_schema` failed with
pydantic 2.12.0a1 due to
pydantic/pydantic#11987.  Since we're testing
the exact contents of the JSON schema, the easiest fix seems to be to
add version-dependent handling for this.
@YuriiMotov
Copy link
Contributor

I just tried running this branch with pydantic 2.12.0a1, and I have 4 failed tests

FAILED tests/test_forms_single_model.py::test_send_all_data - pydantic.warnings.UnsupportedFieldAttributeWarning: The 'alias' attribute with value 'with' was provided to the `Field()` function, which has no effect in the context it was used. 'alias' is field-spec...
FAILED tests/test_forms_single_model.py::test_defaults - pydantic.warnings.UnsupportedFieldAttributeWarning: The 'alias' attribute with value 'with' was provided to the `Field()` function, which has no effect in the context it was used. 'alias' is field-spec...
FAILED tests/test_forms_single_model.py::test_invalid_data - pydantic.warnings.UnsupportedFieldAttributeWarning: The 'alias' attribute with value 'with' was provided to the `Field()` function, which has no effect in the context it was used. 'alias' is field-spec...
FAILED tests/test_forms_single_model.py::test_no_data - pydantic.warnings.UnsupportedFieldAttributeWarning: The 'alias' attribute with value 'with' was provided to the `Field()` function, which has no effect in the context it was used. 'alias' is field-spec...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants