Skip to content

Commit

Permalink
Made setuptools.package_index.Credential a NamedTuple
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Aug 20, 2024
1 parent ebddeb3 commit 11ef30f
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions setuptools/package_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 11ef30f

Please sign in to comment.