diff --git a/.gitignore b/.gitignore index 97fd1a6c..3b2e6588 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ wheels/ .installed.cfg *.egg MANIFEST +pip-wheel-metadata/ # PyInstaller # Usually these files are written by a python script from a template diff --git a/tests/test_auth.py b/tests/test_auth.py index ef0ff1ea..3afedc34 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -7,7 +7,7 @@ ) -cred = auth.CredentialInput.new +cred = auth.CredentialInput @pytest.fixture diff --git a/twine/auth.py b/twine/auth.py index 08bab85e..aa36b3a8 100644 --- a/twine/auth.py +++ b/twine/auth.py @@ -1,7 +1,6 @@ import warnings import getpass import functools -import typing from typing import Optional, Callable import keyring @@ -10,13 +9,11 @@ from . import exceptions -class CredentialInput(typing.NamedTuple): - username: typing.Optional[str] - password: typing.Optional[str] +class CredentialInput: - @classmethod - def new(cls, username=None, password=None): - return cls(username, password) + def __init__(self, username: str = None, password: str = None): + self.username = username + self.password = password class Resolver: @@ -52,7 +49,7 @@ def password(self) -> Optional[str]: def system(self) -> Optional[str]: return self.config['repository'] - def get_username_from_keyring(self): + def get_username_from_keyring(self) -> Optional[str]: try: creds = keyring.get_credential(self.system, None) if creds: @@ -62,13 +59,13 @@ def get_username_from_keyring(self): pass except Exception as exc: warnings.warn(str(exc)) + return None # TODO: mypy shouldn't require this def get_password_from_keyring(self) -> Optional[str]: try: return keyring.get_password(self.system, self.username) except Exception as exc: warnings.warn(str(exc)) - return None # TODO: mypy shouldn't require this return None # any more than it should require this def username_from_keyring_or_prompt(self) -> str: