pydantic-core icon indicating copy to clipboard operation
pydantic-core copied to clipboard

add frozen to Config

Open PrettyWood opened this issue 2 years ago • 4 comments

closes #231

PrettyWood avatar Aug 30 '22 12:08 PrettyWood

I think we need a different error message, e.g something like "Model is frozen", rather than "Field".

samuelcolvin avatar Sep 20 '22 13:09 samuelcolvin

Codecov Report

Merging #237 (3629ce3) into main (837a6ce) will increase coverage by 0.00%. The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #237   +/-   ##
=======================================
  Coverage   98.61%   98.61%           
=======================================
  Files          51       51           
  Lines        5342     5352   +10     
  Branches       39       39           
=======================================
+ Hits         5268     5278   +10     
  Misses         74       74           
Impacted Files Coverage Δ
src/errors/kinds.rs 99.15% <ø> (ø)
pydantic_core/core_schema.py 100.00% <100.00%> (ø)
src/validators/typed_dict.rs 99.12% <100.00%> (+0.02%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 837a6ce...3629ce3. Read the comment docs.

codecov-commenter avatar Oct 02 '22 10:10 codecov-commenter

@samuelcolvin Thanks for your remark and sorry for coming back to it so late. Is https://github.com/pydantic/pydantic-core/pull/237/commits/3629ce31a2664efae8cc75522bbe475e3d150edd ok for you?

PrettyWood avatar Oct 02 '22 10:10 PrettyWood

Maybe it would all be simpler if we just added frozen to SchemaValidator, then check checked in validate_assignment?

That way we can "freeze" any schema.

E.g. if we added validate_assignment logic to tuples, frozen would just work.

If not that, then I think we should just add frozen to TypedDictValidator do the check in TypedDictValidator.validate_assignment.

WDYT?

samuelcolvin avatar Oct 03 '22 11:10 samuelcolvin

replaced by #462

samuelcolvin avatar Mar 27 '23 09:03 samuelcolvin