fix: use dataclasses proxy for frozen or empty dataclasses#4878
fix: use dataclasses proxy for frozen or empty dataclasses#4878samuelcolvin merged 7 commits intopydantic:1.10.X-fixesfrom
Conversation
| import dataclasses | ||
|
|
||
| if is_builtin_dataclass(cls) and _extra_dc_args(_cls) == _extra_dc_args(_cls.__bases__[0]): # type: ignore | ||
| should_use_proxy = ( |
There was a problem hiding this comment.
I reckon I should have added directly the dataclass kwarg use_proxy and invite people to write
PydanticDC = pydantic.dataclasses.dataclass(DC, use_proxy=True) to keep DC untouched.
It would have been explicit for these rare use cases and would have avoided this kind of (very weak) magic
But I reckon it's too late now for v1 and v2 won't need this at all yay 🎉
There was a problem hiding this comment.
you're probably right, but hindsight is a beautiful thing. No worries now.
7d8a168 to
1a3ae7b
Compare
72217a2 to
43892c3
Compare
|
Please review |
samuelcolvin
left a comment
There was a problem hiding this comment.
LGTM!
This looks great, really pleased you were able to fix it so easily, I wasn't sure where to go.
Just one small suggestion, otherwise this is good to go.
Please update.
| frozen: bool = False, | ||
| config: Union[ConfigDict, Type[object], None] = None, | ||
| validate_on_init: Optional[bool] = None, | ||
| use_proxy: Optional[bool] = None, |
There was a problem hiding this comment.
should we allow the validate_on_init and raise a deprecation warning here?
Otherwise this is technically a breaking change.
| import dataclasses | ||
|
|
||
| if is_builtin_dataclass(cls) and _extra_dc_args(_cls) == _extra_dc_args(_cls.__bases__[0]): # type: ignore | ||
| should_use_proxy = ( |
There was a problem hiding this comment.
you're probably right, but hindsight is a beautiful thing. No worries now.
|
please review |
|
please review |
|
thanks so much. |
fix #4498
fix #4565
fix #4877
fix #4585