diff --git a/setuptools/package_index.py b/setuptools/package_index.py index a66cbb2e613..dacfbccebf3 100644 --- a/setuptools/package_index.py +++ b/setuptools/package_index.py @@ -18,6 +18,7 @@ import urllib.request from fnmatch import translate from functools import wraps +from typing import NamedTuple from more_itertools import unique_everseen @@ -1001,21 +1002,14 @@ def _encode_auth(auth): return encoded.replace('\n', '') -class Credential: - """ - A username/password pair. Use like a namedtuple. - """ - - def __init__(self, username, password): - self.username = username - self.password = password +class Credential(NamedTuple): + """A username/password pair.""" - def __iter__(self): - yield self.username - yield self.password + username: str + password: str - def __str__(self): - return '%(username)s:%(password)s' % vars(self) + def __str__(self) -> str: + return f'{self.username}:{self.password}' class PyPIConfig(configparser.RawConfigParser):