{"id":2826,"library":"types-flask","title":"Flask Type Stubs","description":"types-flask is a PEP 561 type stub package providing static type information for the Flask web framework. It allows type-checking tools like MyPy, PyCharm, and Pyright to analyze code that uses Flask, catching potential type-related errors before runtime. The current version is 1.1.6. It is part of the `typeshed` project, which generally releases updates as needed to align with changes in the runtime libraries it provides stubs for, although its primary function for Flask versions 2.0 and newer has been superseded by Flask's native type annotations.","status":"maintenance","version":"1.1.6","language":"en","source_language":"en","source_url":"https://github.com/python/typeshed","tags":["flask","typing","stubs","type-checking","mypy"],"install":[{"cmd":"pip install types-flask","lang":"bash","label":"Install types-flask"}],"dependencies":[{"reason":"Provides type stubs for the Flask web framework.","package":"flask","optional":false}],"imports":[{"note":"types-flask provides type stubs for the 'flask' package; actual imports remain from 'flask'.","wrong":"from types_flask import Flask","symbol":"Flask","correct":"from flask import Flask"}],"quickstart":{"code":"from flask import Flask\n\napp = Flask(__name__)\n\n@app.route('/')\ndef hello_world() -> str:\n    return 'Hello, World!'\n\n# To run (if Flask < 2.0 and types-flask is needed):\n# FLASK_APP=app.py FLASK_ENV=development mypy app.py\n# FLASK_APP=app.py flask run","lang":"python","description":"This minimal Flask application demonstrates basic routing. If you are using Flask version prior to 2.0, `types-flask` would provide type checking for this code. For Flask 2.0 and newer, Flask includes its own type annotations, rendering `types-flask` unnecessary."},"warnings":[{"fix":"Uninstall `types-flask` if you are using Flask 2.0 or a newer version: `pip uninstall types-flask`.","message":"For Flask versions 2.0 and above, the `flask` package itself includes type annotations. Installing `types-flask` alongside Flask 2.0+ can lead to conflicts or redundant type information.","severity":"breaking","affected_versions":"Flask >= 2.0"},{"fix":"Continue to import symbols directly from `flask` (e.g., `from flask import Flask`), as `types-flask` only provides static type definitions for these existing symbols.","message":"`types-flask` is a stub package and does not add any new runtime functionality or modules. All imports should still target the original `flask` library.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consult the `typeshed` repository's `stubs/Flask` directory for details on which `flask` versions are supported by specific `types-flask` releases.","message":"The versioning of `types-flask` is tied to the `typeshed` project and may not directly correspond to specific `flask` package versions. Ensure compatibility by checking `typeshed`'s `Flask` stub history if encountering type-checking issues with specific `flask` versions prior to 2.0.","severity":"gotcha","affected_versions":"< Flask 2.0"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}