diff --git a/src/pdm/models/auth.py b/src/pdm/models/auth.py index e43dcd4bee..890b8b974b 100644 --- a/src/pdm/models/auth.py +++ b/src/pdm/models/auth.py @@ -36,7 +36,7 @@ def _get_auth_from_index_url(self, netloc: str) -> tuple[MaybeAuth, str | None]: parsed = urllib.parse.urlparse(source["url"]) auth, index_netloc = split_auth_from_netloc(parsed.netloc) if index_netloc == netloc: - if "username" in source: + if source.get("username"): auth = (source["username"], source.get("password")) return auth, source["url"] return None, None