✨ Pydantic v2 migration, initial implementation #9500
WIP
e72c4844
✨ Add compat layer, for Pydantic v1 and v2
271cdd1a
✨ Re-export Pydantic needed internals from compat, to later patch the…
eb0f190c
♻️ Refactor internals to use new compatibility layers and run with Py…
4dd362f9
📝 Update examples to run with Pydantic v2
267471c1
✅ Update tests to use Pydantic v2
9ac784f6
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
af6bcb48
✅ Temporarily disable Peewee tests, afterwards I'll enable them only …
c3cd2768
Merge branch 'master' into pydantic-v2-2
25a1b4a8
🔀 Merge master
18fdfff3
🐛 Fix JSON Schema generation and OpenAPI ref template
359bb3b4
🐛 Fix model field creation with defaults from Pydantic v2
b1d350b1
🐛 Fix body field creation, with new FieldInfo
30fc8c24
✨ Use and check new ResponseValidationError for server validation errors
29e070cf
✅ Fix test_schema_extra_examples tests with ResponseValidationError
e7dc1004
✅ Add dirty-equals to tests for compatibility with Pydantic v1 and v2
bfd5fe96
✨ Add util to regenerate errors with custom loc
9151446c
✨ Generate validation errors with loc
07784c3c
✅ Update tests for compatibility with Pydantic v1 and v2
5bb3a63d
✅ Update tests for Pydantic v2 in tests/test_filter_pydantic_sub_mode…
119f7495
✅ Refactor tests in tests/test_dependency_overrides.py for Pydantic v…
9aa34733
✅ Refactor OpenAPI test for tests/test_infer_param_optionality.py for…
68a4b502
✅ Update tests for tests/test_multi_query_errors.py for Pydantic v1 a…
b7286d8c
✅ Update tests for tests/test_multi_body_errors.py for Pydantic v1 an…
cefdb986
✅ Update tests for tests/test_multi_body_errors.py for Pydantic v1 an…
85965a96
🔀 Merge branch 'master' into pydantic-v2-2
9b6f6059
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
51204ab5
♻️ Refactor tests for tests/test_path.py to inline pytest parameters,…
689618ad
✅ Refactor and udpate tests for tests/test_path.py for Pydantic v1 an…
03d04f83
♻️ Refactor and update tests for tests/test_query.py with compatibili…
2fd6af09
✅ Fix test with optional field without default None
dad962b1
✅ Update tests for compatibility with Pydantic v2
7630e86b
✅ Update tutorial tests for Pydantic v2
ce87eeef
♻️ Update OAuth2 dependencies for Pydantic v2
c852ce9b
♻️ Refactor str check when checking for sequence types
15c03d99
♻️ Rename regex to pattern to keep in sync with Pydantic v2
9fb70d10
♻️ Refactor _compat.py, start moving conditional imports and declarat…
c4df438c
✅ Update tests for OAuth2 security optional
f625cfeb
✅ Refactor tests for OAuth2 optional for Pydantic v2
2605f6d9
✅ Refactor tests for OAuth2 security for compatibility with Pydantic v2
837f979f
🐛 Fix location in compat layer for Pydantic v2 ModelField
6416debf
✅ Refactor tests for Pydantic v2 in tests/test_tutorial/test_bigger_a…
5f0eb70d
🐛 Add missing markers in Python 3.9 tests
bf1efd67
✅ Refactor tests for bigger apps for consistency with annotated ones …
068cf38e
🐛 Fix jsonable_encoder with new Pydantic v2 data types and Url
73c922d6
🐛 Fix invalid JSON error for compatibility with Pydantic v2
e05ca798
✅ Update tests for behind_a_proxy for Pydantic v2
268e2262
✅ Update tests for tests/test_tutorial/test_body/test_tutorial001_py3…
82dacd21
✅ Update tests for tests/test_tutorial/test_body/test_tutorial001.py …
16641d4d
✅ Fix tests for tutorial/body_fields for Pydantic v2
ac677d4f
✅ Refactor tests for tutorial/body_multiple_params with Pydantic v2
b6a6b563
✅ Update tests for tutorial/body_nested_models for Pydantic v2
79533d76
✅ Update tests for tutorial/body_updates for Pydantic v2
35019425
✅ Update test for tutorial/cookie_params for Pydantic v2
469233f7
✅ Fix tests for tests/test_tutorial/test_custom_request_and_route/tes…
5d2f7474
✅ Update tests for tutorial/dataclasses for Pydantic v2
9f3c6445
✅ Update tests for tutorial/dependencies for Pydantic v2
0f8f2ce3
✅ Update tests for tutorial/extra_data_types for Pydantic v2
f1adbd2a
✅ Update tests for tutorial/handling_errors for Pydantic v2
58768a03
✅ Fix test markers for Python 3.9
4cd1db61
✅ Update tests for tutorial/header_params for Pydantic v2
51cee6bb
✅ Update tests for Pydantic v2 in tests/test_tutorial/test_openapi_ca…
a1f4ed7c
✅ Fix extra tests for Pydantic v2
9163c7e6
✅ Refactor test for parameters, to later fix Pydantic v2
0c9243a2
✅ Update tests for tutorial/query_params for Pydantic v2
f31aa7da
♻️ Update examples in docs to use new pattern instead of the old regex
902bb27f
✅ Fix several tests for Pydantic v2
c8c3cac8
✅ Update and fix test for ResponseValidationError
fa97a9f0
🐛 Fix check for sequences vs scalars, include bytes as scalar
1b0e7fb7
🐛 Fix check for complex data types, include UploadFile
01c0339a
🐛 Add list to sequence annotation types
6f741c1d
🐛 Fix checks for uploads and add utils to find if an annotation is an…
f7d2f669
✨ Add UnionType and NoneType to compat layer
9a3c5584
✅ Update tests for request_files for compatibility with Pydantic v2 a…
ed3226de
✅ Fix testsw for request_forms for Pydantic v2
4bd0bb63
✅ Fix tests for request_forms_and_files for Pydantic v2
8f92feb0
✅ Fix tests in tutorial/security for compatibility with Pydantic v2
6a4c5d31
⬆️ Upgrade required version of email_validator
5531f843
✅ Fix tests for params repr
ea656032
✅ Add Pydantic v2 pytest markers
a86df8dd
Use match_pydantic_error_url
1e33a4a1
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
153dd0e5
Use field_serializer instead of encoders in some tests
cff5e576
Show Undefined as ... in repr
325ea58d
Mark custom encoders test with xfail
d43c7768
Update test to reflect new serialization of Decimal as str
1a0c361c
Use `model_validate` instead of `from_orm`
6bb2ac43
Update JSON schema to reflect required nullable
5ebe3b6e
Add dirty-equals to pyproject.toml
1efd992e
Use field_serializer instead of encoders in some tests
cff5e576
Show Undefined as ... in repr
325ea58d
Mark custom encoders test with xfail
d43c7768
Use `model_validate` instead of `from_orm`
6bb2ac43
Update JSON schema to reflect required nullable
5ebe3b6e
Fix locs and error creation for use with pydantic 2.0a4
dcc0ad60
Use the type adapter for serialization. This is hacky.
ad840ad2
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
0a0b58e3
✅ Refactor test_multi_body_errors for compatibility with Pydantic v1 …
dd991634
✅ Refactor test_custom_encoder for Pydantic v1 and v2
a963cd9b
✅ Set input to None for now, for compatibility with current tests
2584fbdc
🐛 Fix passing serialization params to model field when handling the r…
a979f3b5
♻️ Refactor exceptions to not depend on Pydantic ValidationError class
81c47ff7
♻️ Revert/refactor params to simplify repr
0c01ca49
✅ Tweak tests for custom class encoders for Pydantic v1 and v2
c17be1ad
✅ Tweak tests for jsonable_encoder for Pydantic v1 and v2
c509a855
✅ Tweak test for compatibility with Pydantic v1 and v2
a761e6e9
🐛 Fix filtering data with subclasses
fe0d7a55
🐛 Workaround examples in OpenAPI schema
272bcec0
✅ Add skip marker for SQL tutorial, needs to be updated either way
247b3285
✅ Update test for broken JSON
d4b4fa16
✅ Fix test for broken JSON
5c3ebf27
✅ Update tests for timedeltas
67e943a1
✅ Fix test for plain text validation errors
d3da7ecb
✅ Add markers for Pydantic v1 exclusive tests (for now)
289b0e10
✅ Update test for path_params with enums for compatibility with Pydan…
2ecafcaf
✅ Update tests for extra examples in OpenAPI
de80d0d6
✅ Fix tests for response_model with compatibility with Pydantic v1 an…
334b4d34
🐛 Fix required double serialization for different types of models
55517b03
✅ Fix tests for response model with compatibility with new Pydantic v2
aad68c4b
🐛 Import Undefined from compat layer
26f45b5a
✅ Fix tests for response_model for Pydantic v2
0c4539d5
✅ Fix tests for schema_extra for Pydantic v2
7c122327
✅ Add markers and update tests for Pydantic v2
37694edd
💡 Comment out logic for double encoding that breaks other usecases
5008948b
✅ Update errors for int parsing
67d6215f
♻️ Refactor re-enabling compatibility for Pydantic v1
f2f6bae8
♻️ Refactor OpenAPI utils to re-enable support for Pydantic v1
6d46f845
♻️ Refactor dependencies/utils and _compat for compatibility with Pyd…
57c782ab
🐛 Fix and tweak compatibility with Pydantic v1 and v2 in dependencies…
67bf59a1
✅ Tweak tests and examples for Pydantic v1
92ecc4e1
♻️ Tweak call to ModelField.validate for compatibility with Pydantic v1
0c3518bd
✨ Use new global override TypeAdapter from_attributes
72477488
✅ Update tests after updating from_attributes
e526a58e
🔧 Update pytest config to avoid collecting tests from docs, useful fo…
c499aebc
✅ Add test for data filtering, including inheritance and models in fi…
29a177b8
♻️ Make OpenAPI models compatible with both Pydantic v1 and v2
5cd20c9d
♻️ Fix compatibility for Pydantic v1 and v2 in jsonable_encoder
db97e589
♻️ Fix compatibility in params with Pydantic v1 and v2
cdf86f1b
♻️ Fix compatibility when creating a FieldInfo in Pydantic v1 and v2 …
a383426f
♻️ Fix generation of flat_models and JSON Schema definitions in _comp…
2e6545ab
♻️ Update handling of ErrorWrappers for Pydantic v1
a05d7b0b
♻️ Refactor checks and handling of types an sequences
6dc62884
♻️ Refactor and cleanup comments with compatibility for Pydantic v1 a…
6acc1199
♻️ Update UploadFile for compatibility with both Pydantic v1 and v2
0e287856
🔥 Remove commented out unneeded code
1af5551b
🐛 Fix mock of get_annotation_from_field_info for Pydantic v1 and v2
3df87c4e
🐛 Fix params with compatibility for Pydantic v1 and v2, with schemas …
b89d5eee
🐛 Fix check if field is sequence for Pydantic v1
442a3d9c
✅ Fix tests for custom_schema_fields, for compatibility with Pydantic…
3ab26146
✅ Simplify and fix tests for jsonable_encoder with compatibility for …
7af61172
✅ Fix tests for orm_mode with Pydantic v1 and compatibility with Pyda…
5cf374f8
♻️ Refactor logic for normalizing Pydantic v1 ErrorWrappers
2a8c4f7e
♻️ Workaround for params with examples, before defining what to depre…
5e57b77f
✅ Fix tests for Pydantic v1 and v2 for response_by_alias
88f1e77b
✅ Fix test for schema_extra with compatibility with Pydantic v1 and v2
073ec1ce
♻️ Tweak error regeneration with loc
ec96cc50
♻️ Update error handling and serializationwith compatibility for Pyda…
431e2a9f
♻️ Re-enable custom encoders for Pydantic v1
5251a194
♻️ Update ErrorWrapper reserialization in Pydantic v1, do it outside …
f5abda63
✅ Update test for filter_submodel, re-structure to simplify testing w…
5df17c56
✅ Refactor Pydantic v1 only test that requires modifying environment …
988109c2
🔥 Update test for plaintext error responses, for Pydantic v1 and v2
b90bca12
⏪️ Revert changes in DB tutorial to use Pydantic v1 (the new guide wi…
fc5c164e
✅ Mark current SQL DB tutorial tests as Pydantic only
cd03085e
🔀 Merge branch 'master' into pydantic-v2-2
04ce5fbe
♻️ Update datastructures for compatibility with Pydantic v1, not requ…
cdbbfe0a
♻️ Update encoders.py for compatibility with Pydantic v1
9ac05afa
⏪️ Revert changes to Peewee, the docs for that are gonna live in a ne…
d27de9cc
♻️ Simplify response body kwargs generation
ab27bc2c
🔥 Clean up comments
b9cec0db
🔥 Clean some tests and comments
cb9f36f9
✅ Refactor tests to match new Pydantic error string URLs
ca8906bc
✅ Refactor tests for recursive models for Pydantic v1 and v2
e517e0a6
✅ Update tests for Peewee, re-enable, Pydantic-v1-only
12aec641
♻️ Update FastAPI params to take regex and pattern arguments
a3335da6
⏪️ Revert tutorial examples for pattern, it will be done in a subsequ…
589c33eb
⏪️ Revert changes in schema extra examples, it will be added later in…
61343060
💡 Add TODO comment to document str validations with pattern
2218be0e
🔥 Remove unneeded comment
960befdd
📌 Upgrade Pydantic pin dependency
461ac06d
🔀 Merge branch 'master' into pydantic-v2-2
582cec13
⬆️ Upgrade email_validator dependency
06a08d66
🐛 Tweak type annotations in _compat.py
f63e1508
🔇 Tweak mypy errors for compat, for Pydantic v1 re-imports
0dffffbd
🐛 Tweak and fix type annotations
5d375388
➕ Update requirements-test.txt, re-add dirty-equals
1dc0a293
🔥 Remove unnecessary config
944ef6bd
🐛 Tweak type annotations
a1318c48
🔥 Remove unnecessary type in dependencies/utils.py
7e2aa140
💡 Update comment in routing.py
8b4a258d
tiangolo
changed the title 🧪 Pydantic v2 migration, investigation, debug (2) ✨ Pydantic v2 migration, initial implementation 1 year ago
tiangolo
changed the base branch from
master
to
main-pv2
1 year ago
tiangolo
marked this pull request as ready for review 1 year ago
tiangolo
merged
bd32feca
into main-pv2 1 year ago
tiangolo
deleted the pydantic-v2-2 branch 1 year ago
Assignees
No one assigned
Login to write a write a comment.
Login via GitHub