quart-cors icon indicating copy to clipboard operation
quart-cors copied to clipboard

Lint Failure when using @route_cors

Open develerltd opened this issue 1 year ago • 1 comments

I have the following python code (python 3.10, quart 0.19.3, quart-cors 0.7.0)

@app.route("/example")
@route_cors(
    allow_headers=["content-type"],
    allow_methods=["GET"],
    allow_origin=["*"],
)
async def config():
    return jsonify({"type": "example"})

And this emits the following linting/typing error:

Argument of type "() -> Coroutine[Any, Any, Response]" cannot be assigned to parameter of type "(**P@route_cors) -> ResponseReturnValue"
  Type "() -> Coroutine[Any, Any, Response]" cannot be assigned to type "(**P@route_cors) -> ResponseReturnValue"
    Function return type "Coroutine[Any, Any, Response]" is incompatible with type "ResponseReturnValue"
      Type "Coroutine[Any, Any, Response]" cannot be assigned to type "ResponseReturnValue"
        "Coroutine[Any, Any, Response]" is incompatible with "Response"
        "Coroutine[Any, Any, Response]" is incompatible with "Response"
        "Coroutine[Any, Any, Response]" is incompatible with "bytes"
        "Coroutine[Any, Any, Response]" is incompatible with "str"
        "Coroutine[Any, Any, Response]" is incompatible with "Mapping[str, Any]"

develerltd avatar Apr 24 '24 12:04 develerltd

I don't have a good solution for this, see https://github.com/python/mypy/issues/16282

pgjones avatar Dec 27 '24 18:12 pgjones