{"id":4302,"library":"types-flask-cors","title":"Typing Stubs for Flask-Cors","description":"Typing stubs for the Flask-Cors library, enabling static type checking for Flask applications that implement Cross-Origin Resource Sharing. This package is part of the typeshed project, a central repository for type annotations, and provides accurate annotations for `Flask-Cors==6.0.*`. Typeshed packages are automatically released to PyPI as needed, often daily.","status":"active","version":"6.0.0.20260408","language":"en","source_language":"en","source_url":"https://github.com/python/typeshed","tags":["typing","stubs","flask","cors","type-checking","typeshed"],"install":[{"cmd":"pip install types-flask-cors","lang":"bash","label":"Install types-flask-cors"}],"dependencies":[{"reason":"This package provides type stubs for the runtime library Flask-Cors, which must be installed separately to provide actual functionality.","package":"Flask-Cors","optional":false}],"imports":[{"note":"This is a stub-only package. You import `CORS` from the `flask_cors` runtime library. `types-flask-cors` provides type hints for static analysis, not runtime functionality.","wrong":"from types_flask_cors import CORS","symbol":"CORS","correct":"from flask_cors import CORS"},{"note":"This is a stub-only package. You import `cross_origin` from the `flask_cors` runtime library. `types-flask-cors` provides type hints for static analysis, not runtime functionality.","wrong":"from types_flask_cors import cross_origin","symbol":"cross_origin","correct":"from flask_cors import cross_origin"}],"quickstart":{"code":"from flask import Flask, jsonify\nfrom flask_cors import CORS\n\napp = Flask(__name__)\n# Enable CORS for all routes and origins\nCORS(app)\n\n@app.route(\"/\")\ndef hello_world():\n    return jsonify({\"message\": \"Hello, cross-origin world!\"})\n\n@app.route(\"/api/data\")\ndef get_data():\n    return jsonify({\"data\": \"This is cross-origin data.\"})\n\nif __name__ == \"__main__\":\n    # Run the app, access at http://127.0.0.1:5000/\n    app.run(debug=True, port=5000)","lang":"python","description":"To use `types-flask-cors`, you first need to set up a basic Flask application with `Flask-Cors` enabled. The `types-flask-cors` package does not require any direct code changes; simply installing it allows your type checker (e.g., MyPy, Pyright) to provide static analysis for your `Flask-Cors` usage."},"warnings":[{"fix":"Install `types-flask-cors` via `pip` and ensure `Flask-Cors` is also installed. Import `CORS` and `cross_origin` from the `flask_cors` runtime library, not `types_flask_cors`.","message":"This is a stub-only package (`.pyi` files) for static type checking. It does not contain any runtime code and should not be imported from directly. Its sole purpose is to provide type hints for the `Flask-Cors` library to tools like MyPy or Pyright.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always ensure the `types-flask-cors` version aligns with the `Flask-Cors` version being used in your project. Refer to the `types-flask-cors` PyPI page for the specific `Flask-Cors` version it targets in its description.","message":"Stub packages from `typeshed`, like `types-flask-cors`, aim to be compatible with a specific major/minor version range of the runtime library. For example, `types-flask-cors==6.0.0.X` is designed for `Flask-Cors==6.0.*`. Mismatched versions can lead to incorrect or incomplete type checking results.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Pin `types-flask-cors` to a specific version (e.g., `types-flask-cors==6.0.0.20260408`) or a compatible range in your `requirements.txt` to mitigate unexpected type-checking failures after updates. Regularly review type checker output after updating stub packages.","message":"While `typeshed` strives for stability, updates to stub packages can introduce changes that cause your code to fail type checking, even if the underlying `Flask-Cors` runtime library has not changed. This is inherent to the nature of refining type definitions and improving type accuracy.","severity":"breaking","affected_versions":"All versions"},{"fix":"Check the `Flask-Cors` documentation or PyPI page for information on native type support. If `Flask-Cors` includes a `py.typed` file, uninstall `types-flask-cors` to avoid potential issues.","message":"If the `Flask-Cors` library itself begins shipping with inline type annotations or its own `py.typed` file in a future version, this `types-flask-cors` stub package will become redundant and may eventually be deprecated or removed from `typeshed`. Installing both could lead to conflicts or degraded type-checking performance.","severity":"deprecated","affected_versions":"Future versions of `Flask-Cors` (if it includes `py.typed`)"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}