Skip to content
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

email_validator package missing in requirements #306

Open
cpaulik opened this issue Apr 28, 2020 · 3 comments
Open

email_validator package missing in requirements #306

cpaulik opened this issue Apr 28, 2020 · 3 comments

Comments

@cpaulik
Copy link

cpaulik commented Apr 28, 2020

You might want to consider adding wtforms[email] as a dependency.

/opt/conda/envs/vds-37/lib/python3.8/site-packages/flask_user/__init__.py:27: in <module>
    from .user_manager import UserManager
/opt/conda/envs/vds-37/lib/python3.8/site-packages/flask_user/user_manager.py:14: in <module>
    from . import forms
/opt/conda/envs/vds-37/lib/python3.8/site-packages/flask_user/forms.py:54: in <module>
    class AddEmailForm(FlaskForm):
/opt/conda/envs/vds-37/lib/python3.8/site-packages/flask_user/forms.py:58: in AddEmailForm
    validators.Email(_('Invalid Email')),
/opt/conda/envs/vds-37/lib/python3.8/site-packages/wtforms/validators.py:332: in __init__
    raise Exception("Install 'email_validator' for email validation support.")
E   Exception: Install 'email_validator' for email validation support.
@honicky
Copy link

honicky commented May 5, 2020

This is a problem for me too. I solved this temporarily by pinning WTForms to 2.2.1 in my own requirements.txt:

WTForms==2.2.1

flask-wtf does not pin the WTForm version, so this could keep happening if Flask-User does not pin the dependencies of flask-wtf. From https://github.com/lepture/flask-wtf/blob/master/setup.py

    install_requires=[
        'Flask',
        'WTForms',
        'itsdangerous',
    ],

An alternative to pinning in Flask-User might be to advise the user in the docs or during startup to pin the sub-dependencies.

@felin-arch
Copy link

felin-arch commented Sep 2, 2020

Yep, I encountered this too, and there isn't much I can do about it. Other than installing the email_validator package, which I won't use. The app I am building does not handle emails at all.

This happens because user_manager imports all forms. And the AddEmailForm calls the validator upon setup. In my opinion the cleanest way to fix this is by requiring the wtforms[email] package, which includes the email_validator as a sub-dependency. This was suggested by @cpaulik as well.

There is a duplicate for this at #313.

@mjpieters
Copy link

The issue is that Flask-User uses the WTForms validators.Email validator, and so should either depend on the wtforms[email] extra. Or it should make the dependency optional as well.

For now, you can work around this by directly depending on wtforms[email], no downgrade necessary.

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

No branches or pull requests

4 participants