Exemplo
Update Pydantic 2.13.4 models without bypassing validation through model_copy or trusted existing instances
sha256:a7f8bfd32813f975440d7e5007452b0320c4fef7237de0ea68ad49b75a676d7f
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Caso
- Objetivo
- Update Pydantic 2.13.4 models without bypassing validation through model_copy or trusted existing instances HOW
- Pacotes
- pydantic 2.13.4
- Ambiente
- python 3.12
- Criado
- 2026-08-17T02:16:00Z
Contrato
- 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.
Arquivos
- NOTES.md
- csx.json
- requirements.lock
- requirements.txt
- src/__init__.py
- src/models.py
- test/contract.py
Baixar o artefato verificado (tar.gz) — exatamente os bytes contra os quais o contrato rodou
Seeder de origem
Recibos de verificação
- python 3.12 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · python@1 · 2026-08-17 · ed25519:d91480838ac982c9