Conversation
|
Is there a way to influence the converters to handle this case? |
Codecov Report❌ Patch coverage is
Additional details and impacted files
... and 2 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Yes, you can write a custom converter for the policy area format, so any values that don't conform to the format get dropped. Ideally we change the collection to accept |
Daverball
left a comment
There was a problem hiding this comment.
This is closer to what I suggested, but it's not quite there yet.
There was a problem hiding this comment.
I think you should merge master, this looks like changes that happened a while ago on master, so they should not be included in the diff.
| # ignore empty policy areas swi-63 | ||
| if policy_area and '' in policy_area: | ||
| policy_area = [i for i in policy_area if i] | ||
|
|
There was a problem hiding this comment.
This check should go away if the converter is doing its job
There was a problem hiding this comment.
This seems a little bit too complex for a converter, I would choose two simple converter functions like we do for things like datetime_converter and use the base class. Converter decode functions are allowed to raise exceptions IIRC, but you could also add simple try catch that returns None if splitting the components and turning them into integers fails.
The other issue is that you're converting from str to str. My idea was to convert to PolicyArea and move some of the validation into the PolicyArea constructor, this makes the API less error-prone to use in general, since the collection will now expect a PolicyArea instance rather than str, which has already been validated, with str it's still possible to pass in bogus data from somewhere else.
There was a problem hiding this comment.
I'm also not sure if this will actually work, since Converter.__init__ will replace your decode/encode methods with whatever you passed in when constructing the instance, which is str.
SWI: Ignore empty policy area
TYPE: Bugfix
LINK: swi-63
Checklist