From a287a0bff360414c38bc0540d28653cd8ffe4ce1 Mon Sep 17 00:00:00 2001 From: Donald Stufft Date: Sat, 25 Jun 2022 14:17:04 -0400 Subject: [PATCH] Use a tuple and one call to startswith --- src/pip/_internal/index/collector.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/pip/_internal/index/collector.py b/src/pip/_internal/index/collector.py index 3aaf5ceee4c..2e219021548 100644 --- a/src/pip/_internal/index/collector.py +++ b/src/pip/_internal/index/collector.py @@ -83,11 +83,13 @@ def _ensure_api_header(response: Response) -> None: content_type = response.headers.get("Content-Type", "") content_type_l = content_type.lower() - if content_type_l.startswith("text/html"): - return - elif content_type_l.startswith("application/vnd.pypi.simple.v1+html"): - return - elif content_type_l.startswith("application/vnd.pypi.simple.v1+json"): + if content_type_l.startswith( + ( + "text/html", + "application/vnd.pypi.simple.v1+html", + "application/vnd.pypi.simple.v1+json", + ) + ): return raise _NotAPIContent(content_type, response.request.method)