-
-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
forbid_extra_keys or hooks get loss with Converter.copy() #410
Comments
Hm you're right for |
Actually I was wrong, it should be using the value from the origin converter ( cattrs/src/cattrs/converters.py Line 1065 in 992b137
|
Ah I see the issue, it's unrelated to copying though. def camel_structure(cls: Any) -> Any:
return cattrs.gen.make_dict_structure_fn(
cls,
camel,
**{
a.name: cattrs.gen.override(rename=to_camel(a.name))
for a in attrs.fields(cls)
},
) I think you were assuming the def camel_structure(cls: Any) -> Any:
return cattrs.gen.make_dict_structure_fn(
cls,
camel,
_cattrs_forbid_extra_keys=camel.forbid_extra_keys,
**{
a.name: cattrs.gen.override(rename=to_camel(a.name))
for a in attrs.fields(cls)
},
) We could make the |
Having given this some more thought I think it does make sense to change the defaults, long term. I'm preparing a PR to make this change. |
Description
Hi, I noticed some issues with
Converter.copy()
where in some caseforbid_extra_keys
or hooks get loss.What I Did
Here's some code reproducing the issue:
The text was updated successfully, but these errors were encountered: