-
Notifications
You must be signed in to change notification settings - Fork 117
Correctly handle None, add tests for other invalid types #155
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: main
Are you sure you want to change the base?
Correctly handle None, add tests for other invalid types #155
Conversation
Hi. Thanks. But there are two reasons I can't accept this as-is:
|
Hey @JoshData - I'm happy to make any required adjustments. My original intent was to keep the changes as minimal as possible - which lead me to this solution. I agree that explicitly checking is the better way to go about this. I also agree that From the perspective of a user of this library. I have a value and I want to use this tool to verify that value is a email address. Per the docs 'Quick Start' , I've setup a try/except block with Just from my point of view, its unexpected behavior that I need to do some validation on the potential email address before handing it off to the library to the rest of the email validation. Perhaps a new exception can be created that extends How does that sound? Do you have any better naming ideas instead of |
I don't think that's the right way of looking at this case. If you don't use a function according to its documentation, a TypeError or ValueError is common and is usually a good thing because it tells you there is an error in your code that probably should be fixed. |
Thanks for the update @JoshData. I think I'm getting a clearer picture of expectations now. So, in the case that python-email-validator/email_validator/validate_email.py Lines 62 to 66 in 8043de4
|
That makes sense. That code block is very old and not documented so I wasn't really thinking about that part carefully. Updating the exception is a good idea. |
Why I made this PR
Hello! It seems calling
.decode
onNone
raises anAttributeError
- which is unfortunately not handled by this library. Callingvalidate_email(None)
generates this exception:What is included in the PR
I've added a catch for the
AttributeError
and some additional tests for invalid types.Thank you for maintaining this library!