mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
d8e8e6a780
* feature: add a `frozen` parameter to config For now, `frozen` is a strict duplication of `allow_mutation` parameter i.e. setting `frozen=True` does everything that `allow_mutation=False` does. NB: this does not change the behavior of `allow_mutation`. In next commit, setting `frozen=True` will also make the BaseModel hashable while the existing behavior of `allow_mutation` will not be updated. * refactor: factorise immutability tests * feature: generate a hash function when frozen is True Now, setting `frozen=True` also generate a hash function for the model i.e. `__hash__` is not `None`. This makes instances of the model potentially hashable if all the attributes are hashable. (default: `False`) * reviewer feedback: use hash of the class instead of the super * reviewer feedback: fix spelling checks * reviewer feedback: update changes description * test: remwork mypy tests in order to catch only frozen related errors Before: there were errors about other stuff than frozen behavior After: The modification catch only errot related to the frozen behavior * test: split test_immutablity in 2 functions One function tests the behavior: 'the model is mutable' The other tests the behavior:OC 'the model is immutable' * test mutability: remove the unnecessary parametrization * test immutability: remove assertion that do not test frozen behavior
28 lines
2.1 KiB
Plaintext
28 lines
2.1 KiB
Plaintext
24: error: Unexpected keyword argument "z" for "Model" [call-arg]
|
|
25: error: Missing named argument "y" for "Model" [call-arg]
|
|
26: error: Property "y" defined in "Model" is read-only [misc]
|
|
27: error: "Model" does not have orm_mode=True [pydantic-orm]
|
|
36: error: Unexpected keyword argument "x" for "ForbidExtraModel" [call-arg]
|
|
47: error: Unexpected keyword argument "x" for "ForbidExtraModel2" [call-arg]
|
|
53: error: Invalid value for "Config.extra" [pydantic-config]
|
|
58: error: Invalid value for "Config.orm_mode" [pydantic-config]
|
|
63: error: Invalid value for "Config.orm_mode" [pydantic-config]
|
|
74: error: Incompatible types in assignment (expression has type "ellipsis", variable has type "int") [assignment]
|
|
87: error: Missing named argument "a" for "DefaultTestingModel" [call-arg]
|
|
87: error: Missing named argument "b" for "DefaultTestingModel" [call-arg]
|
|
87: error: Missing named argument "c" for "DefaultTestingModel" [call-arg]
|
|
87: error: Missing named argument "d" for "DefaultTestingModel" [call-arg]
|
|
87: error: Missing named argument "e" for "DefaultTestingModel" [call-arg]
|
|
91: error: Name 'Undefined' is not defined [name-defined]
|
|
94: error: Missing named argument "undefined" for "UndefinedAnnotationModel" [call-arg]
|
|
101: error: Missing named argument "y" for "construct" of "Model" [call-arg]
|
|
103: error: Argument "x" to "construct" of "Model" has incompatible type "str"; expected "int" [arg-type]
|
|
156: error: Missing named argument "x" for "DynamicAliasModel2" [call-arg]
|
|
175: error: unused 'type: ignore' comment
|
|
182: error: unused 'type: ignore' comment
|
|
189: error: Name 'Missing' is not defined [name-defined]
|
|
197: error: No overload variant of "dataclass" matches argument type "Dict[<nothing>, <nothing>]" [call-overload]
|
|
197: note: Possible overload variant:
|
|
197: note: def dataclass(*, init: bool = ..., repr: bool = ..., eq: bool = ..., order: bool = ..., unsafe_hash: bool = ..., frozen: bool = ..., config: Optional[Type[Any]] = ...) -> Callable[[Type[Any]], Type[Dataclass]]
|
|
197: note: <1 more non-matching overload not shown>
|
|
219: error: Property "y" defined in "FrozenModel" is read-only [misc] |