From 6b18cd11ca6c38e2e43fbb71450ec5bdc6b321b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=A9=EC=84=B1=EB=B2=94=20=28Bang=20Seongbeom=29?= Date: Sat, 18 Apr 2026 02:06:41 +0900 Subject: [PATCH 1/2] Refactor WSGIEnvironment to use TypedDict --- Lib/wsgiref/types.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/Lib/wsgiref/types.py b/Lib/wsgiref/types.py index ef0aead5b28b64..67894da933d49c 100644 --- a/Lib/wsgiref/types.py +++ b/Lib/wsgiref/types.py @@ -2,7 +2,7 @@ from collections.abc import Callable, Iterable, Iterator from types import TracebackType -from typing import Any, Protocol, TypeAlias +from typing import Any, Literal, NotRequired, Protocol, TypeAlias, TypedDict __all__ = [ "StartResponse", @@ -26,7 +26,29 @@ def __call__( /, ) -> Callable[[bytes], object]: ... -WSGIEnvironment: TypeAlias = dict[str, Any] +WSGIEnvironment = TypedDict( + "WSGIEnvironment", + { + "REQUEST_METHOD": str, + "SCRIPT_NAME": NotRequired[str], + "PATH_INFO": NotRequired[str], + "QUERY_STRING": NotRequired[str], + "CONTENT_TYPE": NotRequired[str], + "CONTENT_LENGTH": NotRequired[str], + "SERVER_NAME": str, + "SERVER_PORT": str, + "SERVER_PROTOCOL": str, + "wsgi.version": tuple[Literal[1], Literal[0]], + "wsgi.url_scheme": str, + "wsgi.input": "InputStream", + "wsgi.errors": "ErrorStream", + "wsgi.multithread": Any, + "wsgi.multiprocess": Any, + "wsgi.run_once": Any, + "wsgi.file_wrapper": NotRequired["FileWrapper"], + }, + extra_items=Any, +) WSGIApplication: TypeAlias = Callable[[WSGIEnvironment, StartResponse], Iterable[bytes]] From 58ab6f655f9f0c650aac7447d7cfa8d24098af16 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2026 18:24:37 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2026-04-20-18-24-36.gh-issue-86178.5gTefv.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2026-04-20-18-24-36.gh-issue-86178.5gTefv.rst diff --git a/Misc/NEWS.d/next/Library/2026-04-20-18-24-36.gh-issue-86178.5gTefv.rst b/Misc/NEWS.d/next/Library/2026-04-20-18-24-36.gh-issue-86178.5gTefv.rst new file mode 100644 index 00000000000000..c9058f672aa2f6 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-04-20-18-24-36.gh-issue-86178.5gTefv.rst @@ -0,0 +1 @@ +Add the CGI and WSGI variables specified in :pep:`3333` to :data:`wsgiref.types.WSGIEnvironment`.