-
-
Notifications
You must be signed in to change notification settings - Fork 114
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
[Feature] Throw error when structuring dict w/ extra keys #101
Comments
If this is something that you'd be open to (either as the default behavior, or as a flag on |
Hello, I'm not really open to changing the default behavior since that would make it very hard to implement backwards compatibility for a lot of use cases cattrs is used for. I would be open to including this as an option. This should be a new parameter to |
Would this solution allow us to set this as the "standard" behavior of a |
Implementing the functionality in |
Another +1 for this feature. I'm open to doing some work on a PR if no one else has one open already. |
@bkurtz Sure, go for it (minding my previous comments). Since there is interest for this I might do this myself in a week if no one else steps up. |
Description
Right now,
cattr.structure
will silently ignore extra keys when structuring into an attrs object:I assume this is intended behavior (since I believe this changed since cattrs 0.9), but it'd be nice to have an option to throw an error on extra keys instead.
In our particular use-case, we are using cattrs and attrs to verify some configuration files we are using, some of which have default keys:
b/c of this "silently allow extra keys" behavior,
cattr.structure
doesn't catch typos (e.g.some_key
vssme_key
), because it will just ignore the incorrectly-typed key and use the default value for the substitute.The text was updated successfully, but these errors were encountered: