Skip to content

Commit

Permalink
Revert bump on python-multipart (#2737)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kludex authored Oct 27, 2024
1 parent 18bbb5c commit f9ffd62
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dependencies = [
full = [
"itsdangerous",
"jinja2",
"python-multipart>=0.0.13",
"python-multipart>=0.0.7",
"pyyaml",
"httpx>=0.22.0",
]
Expand Down
21 changes: 13 additions & 8 deletions starlette/formparsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@

from starlette.datastructures import FormData, Headers, UploadFile

try:
import python_multipart as multipart
from python_multipart.multipart import parse_options_header
except ModuleNotFoundError: # pragma: no cover
parse_options_header = None # type: ignore
multipart = None # type: ignore

if typing.TYPE_CHECKING:
from python_multipart.multipart import MultipartCallbacks, QuerystringCallbacks
import multipart
from multipart.multipart import MultipartCallbacks, QuerystringCallbacks, parse_options_header
else:
try:
try:
import python_multipart as multipart
from python_multipart.multipart import parse_options_header
except ModuleNotFoundError: # pragma: no cover
import multipart
from multipart.multipart import parse_options_header
except ModuleNotFoundError: # pragma: no cover
multipart = None
parse_options_header = None


class FormMessage(Enum):
Expand Down
16 changes: 10 additions & 6 deletions starlette/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@
from starlette.formparsers import FormParser, MultiPartException, MultiPartParser
from starlette.types import Message, Receive, Scope, Send

try:
from python_multipart.multipart import parse_options_header
except ModuleNotFoundError: # pragma: no cover
parse_options_header = None # type: ignore


if typing.TYPE_CHECKING:
from multipart.multipart import parse_options_header

from starlette.applications import Starlette
from starlette.routing import Router
else:
try:
try:
from python_multipart.multipart import parse_options_header
except ModuleNotFoundError: # pragma: no cover
from multipart.multipart import parse_options_header
except ModuleNotFoundError: # pragma: no cover
parse_options_header = None


SERVER_PUSH_HEADERS_TO_COPY = {
Expand Down

0 comments on commit f9ffd62

Please sign in to comment.