From ccf4255dc0a8ea155de9a364c0ce1d79eb990165 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 24 Jan 2024 12:48:59 +0000 Subject: [PATCH] Use more precise type for formparser.MultiPartParser.parse return Without this change, `pyright` with `typeCheckingMode` set to `strict` reports: ``` error: Type of "fields" is partially unknown Type of "fields" is "MultiDict[Unknown, Unknown]" (reportUnknownVariableType) ``` when I use this method. --- CHANGES.rst | 5 +++++ src/werkzeug/formparser.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 186e8f580a..dfb9a9532e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,5 +1,10 @@ .. currentmodule:: werkzeug +Version 3.0.2 +------------- + +- Make the return type of ``MultiPartParser.parse`` more precise. :issue:`2840` + Version 3.0.1 ------------- diff --git a/src/werkzeug/formparser.py b/src/werkzeug/formparser.py index ee30666dd1..5117a26736 100644 --- a/src/werkzeug/formparser.py +++ b/src/werkzeug/formparser.py @@ -352,7 +352,7 @@ def start_file_streaming( def parse( self, stream: t.IO[bytes], boundary: bytes, content_length: int | None - ) -> tuple[MultiDict, MultiDict]: + ) -> tuple[MultiDict[str, str], MultiDict[str, FileStorage]]: current_part: Field | File container: t.IO[bytes] | list[bytes] _write: t.Callable[[bytes], t.Any]