-
Notifications
You must be signed in to change notification settings - Fork 2
Bugfix/swi 63 handle empty policy area #1933
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
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is closer to what I suggested, but it's not quite there yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check should go away if the converter is doing its job
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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