Skip to content

Flask 2.0 uses implicit reexports which mypy complains about #4024

@scottbelden

Description

@scottbelden

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions