Skip to content

Protect custom type testers against None values#66

Merged
abulte merged 2 commits intomasterfrom
fix-siren-type-tester
Oct 15, 2020
Merged

Protect custom type testers against None values#66
abulte merged 2 commits intomasterfrom
fix-siren-type-tester

Conversation

@abulte
Copy link
Contributor

@abulte abulte commented Oct 15, 2020

@abulte abulte requested a review from AntoineAugusti October 15, 2020 07:11
Copy link
Member

@AntoineAugusti AntoineAugusti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work, sorry I miss the None case for SIREN/SIRET! 👏 for the tests

Comment on lines +28 to +29
if d is None:
return d
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? The next line casts to a string before trying to match the regex.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests fail w/o this so I guess so :-)

def cast(self, d):
if d is None:
return d
if is_valid_siret(d) or is_valid_siren(d):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions don't crash for non-string arguments?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the tests cover this. And I'd say every value come as a string since it's a CSV and we're trying to guess types.

@abulte abulte merged commit 7cb2993 into master Oct 15, 2020
@abulte abulte deleted the fix-siren-type-tester branch October 15, 2020 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CSV file w/ double carriage return break the SIREN/SIRET detector

2 participants