diff --git a/starlette/formparsers.py b/starlette/formparsers.py index 8ab5d664c2..eb3cba5bed 100644 --- a/starlette/formparsers.py +++ b/starlette/formparsers.py @@ -9,7 +9,7 @@ try: import multipart from multipart.multipart import parse_options_header -except ImportError: # pragma: nocover +except ModuleNotFoundError: # pragma: nocover parse_options_header = None multipart = None diff --git a/starlette/requests.py b/starlette/requests.py index 0351aee7dc..2ee0c29640 100644 --- a/starlette/requests.py +++ b/starlette/requests.py @@ -12,7 +12,7 @@ try: from multipart.multipart import parse_options_header -except ImportError: # pragma: nocover +except ModuleNotFoundError: # pragma: nocover parse_options_header = None diff --git a/starlette/schemas.py b/starlette/schemas.py index f3d1a84987..f939cb5a31 100644 --- a/starlette/schemas.py +++ b/starlette/schemas.py @@ -8,7 +8,7 @@ try: import yaml -except ImportError: # pragma: nocover +except ModuleNotFoundError: # pragma: nocover yaml = None # type: ignore[assignment] diff --git a/starlette/templating.py b/starlette/templating.py index cce09471f2..7df8f6d29b 100644 --- a/starlette/templating.py +++ b/starlette/templating.py @@ -18,7 +18,7 @@ pass_context = jinja2.pass_context else: # pragma: nocover pass_context = jinja2.contextfunction # type: ignore[attr-defined] -except ImportError: # pragma: nocover +except ModuleNotFoundError: # pragma: nocover jinja2 = None # type: ignore[assignment]