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

Flask 2.0 uses implicit reexports which mypy complains about #4024

Closed
scottbelden opened this issue May 12, 2021 · 1 comment · Fixed by #4042
Closed

Flask 2.0 uses implicit reexports which mypy complains about #4024

scottbelden opened this issue May 12, 2021 · 1 comment · Fixed by #4042
Assignees
Labels
Milestone

Comments

@scottbelden
Copy link

Now that flask 2.0.0 has a py.typed file, the flask types are preferred over the typeshed hints. When running mypy on my code, I now see errors like the following:

 app.py:6: error: Module 'flask' does not explicitly export attribute 'Flask'; implicit reexport disabled
 app.py:6: error: Module 'flask' does not explicitly export attribute 'render_template'; implicit reexport disabled
 app.py:6: error: Module 'flask' does not explicitly export attribute 'request'; implicit reexport disabled
 app.py:6: error: Module 'flask' does not explicitly export attribute 'flash'; implicit reexport disabled
 app.py:6: error: Module 'flask' does not explicitly export attribute 'send_file'; implicit reexport disabled

In flask/__init__.py there are lines like this:

from .app import Flask

However, mypy expects that these reexports should either have an __all__ to explicitly say which variables are being reexported, or to change the import to from .app import Flask as Flask

In typeshed there is an example of how this was done before flask including typing: https://github.com/python/typeshed/blob/6bb1d885c696914e5900329c3d0b6bf2bfefee81/stubs/Flask/flask/__init__.pyi

Environment:

  • Python version: 3.9
  • Flask version: 2.0.0
@davidism
Copy link
Member

davidism commented May 12, 2021

Duplicate of pallets/jinja#1426

See python/mypy#10198 for discussion on changing this behavior.

@davidism davidism marked this as a duplicate of pallets/jinja#1426 May 12, 2021
@davidism davidism reopened this May 12, 2021
@davidism davidism added this to the 2.0.1 milestone May 12, 2021
@davidism davidism self-assigned this May 13, 2021
@davidism davidism mentioned this issue May 13, 2021
3 tasks
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants