SemanticDiff fastapi
✨ Pydantic v2 migration, initial implementation
#9500
Merged

✨ Pydantic v2 migration, initial implementation #9500

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

Login to write a write a comment.

Login via GitHub

Reviewers
No reviews
Assignees
No one assigned
Labels
Milestone