django-stubs
django-stubs copied to clipboard
Incompatibility between WSGIHandler and stdlib types in wsgiref
Bug report
What's wrong
Changes to typing of core.handlers.WSGIHandler introduced in #909 are incompatible with the stdlib annotations under wsgiref, raising a error when checked with mypy:
from wsgiref.simple_server import make_server
from django.core.handlers.wsgi import WSGIHandler
make_server(
"0.0.0.0",
8080,
WSGIHandler(),
)
example.py:8: error: Argument 3 to "make_server" has incompatible type "WSGIHandler"; expected "Callable[[Dict[str, Any], StartResponse], Iterable[bytes]]" [arg-type]
scce.py:8: note: "WSGIHandler.__call__" has type "Callable[[Arg(Dict[str, Any], 'environ'), Arg(Callable[[str, Sequence[Tuple[str, str]], Optional[Any]], None], 'start_response')], HttpResponseBase]"
Found 1 error in 1 file (checked 1 source file)
wsgiref types are in typeshed Python <= 3.10, and in wsgiref.types as of Python 3.11.
How is that should be
Types should be compatible with stdlib as per PEP 3333.
System information
- OS:
pythonversion: 3.10djangoversion: 4.0.5mypyversion: 0.961django-stubsversion: 1.12.0django-stubs-extversion: 0.5.0