From d8a04c782f424365f5b9fcd54bee0c4bf0d3180a Mon Sep 17 00:00:00 2001 From: Rishab Motgi Date: Mon, 18 May 2026 16:22:19 -0700 Subject: [PATCH] fix: use tuple comparison for python-multipart version check String comparison is lexicographic, so "0.0.100" > "0.0.12" evaluates to False ("1" < "9" by char code). A valid python-multipart==0.0.100+ installation was incorrectly rejected as too old, raising multipart_not_installed_error on any Form() or File() endpoint. Parse the version into an integer tuple before comparing so numeric ordering is used instead. --- fastapi/dependencies/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastapi/dependencies/utils.py b/fastapi/dependencies/utils.py index 7c6558c695..0bfb36e2a5 100644 --- a/fastapi/dependencies/utils.py +++ b/fastapi/dependencies/utils.py @@ -96,7 +96,7 @@ def ensure_multipart_is_installed() -> None: from python_multipart import __version__ # Import an attribute that can be mocked/deleted in testing - assert __version__ > "0.0.12" + assert tuple(int(x) for x in __version__.split(".")[:3]) > (0, 0, 12) except (ImportError, AssertionError): try: # __version__ is available in both multiparts, and can be mocked