-
-
Notifications
You must be signed in to change notification settings - Fork 16.7k
Closed
Description
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:
Line 7 in d575de5
| 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
scirelli-c1, andreymal and jugmac00