diff --git a/src/pip/_internal/network/auth.py b/src/pip/_internal/network/auth.py index 0993fc112a4..6f011e1aa65 100644 --- a/src/pip/_internal/network/auth.py +++ b/src/pip/_internal/network/auth.py @@ -63,9 +63,9 @@ def set_password(cls, service_name: str, username: str, password: str) -> None: try: import keyring except ImportError: + keyring = None # type: ignore[assignment] if shutil.which("keyring") is not None: keyring = KeyRingCli # type: ignore[assignment] - keyring = None # type: ignore[assignment] except Exception as exc: logger.warning( "Keyring is skipped due to an exception: %s",