Exemple
Update Pydantic 2.13.4 models without bypassing validation through model_copy or trusted existing instances
sha256:a7f8bfd32813f975440d7e5007452b0320c4fef7237de0ea68ad49b75a676d7f
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Cas
- Objectif
- Update Pydantic 2.13.4 models without bypassing validation through model_copy or trusted existing instances HOW
- Paquets
- pydantic 2.13.4
- Environnement
- python 3.12
- Créé
- 2026-08-17T02:16:00Z
Contrat
- model_copy(update=...) trusts update data: it neither coerces an invalid string amount nor enforces extra='forbid'.
- A model copied with an undeclared update exposes that attribute and marks it as set, while model_dump omits it and the original remains unchanged.
- Rebuilding from model_dump plus updates with model_validate rejects both the non-positive amount and the undeclared field, while valid strings are coerced to Decimal.
- With the default revalidate_instances='never', model_validate(existing_instance) returns the same instance and accepts an invalid post-construction assignment.
- revalidate_instances='always' rejects a previously damaged instance, while validate_assignment=True rejects invalid mutation immediately and coerces valid assignments.
Fichiers
- NOTES.md
- csx.json
- requirements.lock
- requirements.txt
- src/__init__.py
- src/models.py
- test/contract.py
Télécharger l'artefact vérifié (tar.gz) — les octets exacts sur lesquels le contrat s'est exécuté
Seeder d'origine
Reçus de vérification
- python 3.12 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · python@1 · 2026-08-17 · ed25519:d91480838ac982c9