Could we fail on unknown Attribute?
See original GitHub issueCould we please add another config option in addition to fail_on_unknown_properties
to fail on unknown Attribute
?
I don’t currently see that functionality and I’ve experimented by adding random attributes to my parser and they didn’t crash or raise a TypeError
.
I am using attrs
plugin with the kw_only
flag set to true
in the config.
I would be expecting similar behaviour to this:
In [1]: import attr
In [2]: @attr.s(frozen=True, slots=True, kw_only=True)
...: class Test:
...: a: int = attr.ib()
...: b: str = attr.ib()
In [3]: Test(**{'a': 3, 'b': 'test', 'c': 'tent'})
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-10-715d11a185fb> in <module>
----> 1 Test(**{'a': 3, 'b': 'test', 'c': 'tent'})
TypeError: __init__() got an unexpected keyword argument 'c'
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
failing on unknown properties w/notification
The DeserializationProblemHandler class seems to do what you want. It allows you to implement this method to handle unknown properties:
Read more >Unknown attributes should be a warning (not an error)
Can the core team consider making unknown attributes a warning rather than an error? In this case, if, say, @inline(__always) is removed, ...
Read more >Agile Central: Custom List App - fetchWsapiRecords error
Suddenly, there is an error with "Custom List With Deep Export" app. The error reads: fetchWsapiRecords error: Cannot sort using unknown ...
Read more >Jackson Unmarshalling JSON with Unknown Properties
In this tutorial, we're going to take a look at the unmarshalling process with Jackson 2.x, specifically how to deal with JSON content...
Read more >How to Ignore Unknown Properties While Parsing JSON in ...
Another way to deal with unknown properties in JSON you are parsing is to configure ObjectMapper not to fail when it encounters an...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
looks great @pashashocky feel free to submit a pull-request
@tefra thank you, was a pleasure - and appreciate the tips!