Type Issue when Passing Flask App to WSGIMiddleware
cancan101 opened this issue · 1 comments
cancan101 commented
I am attempting to pass a flask app to WSGIMiddleware
:
from a2wsgi import WSGIMiddleware
from flask import Flask
app = Flask(__name__)
mw = WSGIMiddleware(app=app)
but am getting the following error from mypy:
my_app/__init__.py:14: error: Argument "app" to "WSGIMiddleware" has incompatible type "Flask"; expected "Callable[[MutableMapping[str, Any], Callable[[str, Iterable[Tuple[str, str]], Optional[Tuple[Type[BaseException], BaseException, Optional[TracebackType]]]], None]], Iterable[bytes]]" [arg-type]
my_app/__init__.py:14: note: "Flask.__call__" has type "Callable[[Arg(Dict[Any, Any], 'environ'), Arg(Callable[..., Any], 'start_response')], Any]"
Using:
flask==2.2.3
a2wsgi==1.7.0
abersheeran commented
WSGI does not have a unified Type hint Interface so far. You can temporarily use type: ignore
to solve the problem.
Some related issues: python/typing#795