Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatibility between WSGIHandler and stdlib types in wsgiref #1053

Closed
edwardpeek-crown opened this issue Jul 7, 2022 · 0 comments · Fixed by #1639
Closed

Incompatibility between WSGIHandler and stdlib types in wsgiref #1053

edwardpeek-crown opened this issue Jul 7, 2022 · 0 comments · Fixed by #1639
Labels
bug Something isn't working stubs Issues in stubs files (.pyi)

Comments

@edwardpeek-crown
Copy link

edwardpeek-crown commented Jul 7, 2022

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:
  • python version: 3.10
  • django version: 4.0.5
  • mypy version: 0.961
  • django-stubs version: 1.12.0
  • django-stubs-ext version: 0.5.0
@edwardpeek-crown edwardpeek-crown added the bug Something isn't working label Jul 7, 2022
@intgr intgr added the stubs Issues in stubs files (.pyi) label Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stubs Issues in stubs files (.pyi)
Development

Successfully merging a pull request may close this issue.

2 participants