Skip to content

Commit

Permalink
Smaller message when keyring installed but finds no backend
Browse files Browse the repository at this point in the history
  • Loading branch information
takluyver committed Dec 8, 2024
1 parent 60b3327 commit 7eb4947
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions twine/auth.py
Original file line number Diff line number Diff line change
@@ -13,11 +13,14 @@
# pre-built wheels for ppc64le and s390x, see #1158.
if TYPE_CHECKING:
import keyring
from keyring.errors import NoKeyringError
else:
try:
import keyring
from keyring.errors import NoKeyringError
except ModuleNotFoundError: # pragma: no cover
keyring = None
NoKeyringError = None

from twine import exceptions
from twine import utils
@@ -156,6 +159,8 @@ def get_password_from_keyring(self) -> Optional[str]:
username = cast(str, self.username)
logger.info("Querying keyring for password")
return cast(str, keyring.get_password(system, username))
except NoKeyringError:
logger.info("No keyring backend found")
except Exception as exc:
logger.warning("Error getting password from keyring", exc_info=exc)
return None

0 comments on commit 7eb4947

Please sign in to comment.