From 70ad4d6d9b330e8dc780e53470e261cb096fd5fc 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 | 8 ++++++++ src/werkzeug/formparser.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 186e8f580..b23bffcd4 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,5 +1,13 @@ .. currentmodule:: werkzeug +Version 3.0.2 +------------- + +Unreleased + +- 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 ee30666dd..5117a2673 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]