diff --git a/lib50/authentication.py b/lib50/authentication.py index cc98ab0..d97a550 100644 --- a/lib50/authentication.py +++ b/lib50/authentication.py @@ -1,5 +1,5 @@ -import attr import contextlib +import dataclasses import enum import os import pexpect @@ -20,16 +20,18 @@ _CREDENTIAL_SOCKET = Path("~/.git-credential-cache/lib50").expanduser() -@attr.s(slots=True) +@dataclasses.dataclass class User: """An authenticated GitHub user that has write access to org/repo.""" - name = attr.ib() - repo = attr.ib() - org = attr.ib() - passphrase = attr.ib(default=str) - email = attr.ib(default=attr.Factory(lambda self: f"{self.name}@users.noreply.github.com", - takes_self=True), - init=False) + name: str + repo: str + org: str + passphrase: str = "" + email: str = dataclasses.field(init=False) + + def __post_init__(self): + self.email = f"{self.name}@users.noreply.github.com" + @contextlib.contextmanager def authenticate(org, repo=None, auth_method=None): diff --git a/setup.py b/setup.py index 1ca5d1c..e5835be 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ license="GPLv3", description="This is lib50, CS50's own internal library used in many of its tools.", long_description="This is lib50, CS50's own internal library used in many of its tools.", - install_requires=["attrs>=18.1,<21", "packaging", "pexpect>=4.6,<5", "pyyaml<7", "requests>=2.13,<3", "setuptools", "termcolor>=1.1,<2", "jellyfish>=1,<2", "cryptography>=2.7"], + install_requires=["packaging", "pexpect>=4.6,<5", "pyyaml<7", "requests>=2.13,<3", "setuptools", "termcolor>=1.1,<2", "jellyfish>=1,<2", "cryptography>=2.7"], extras_require = { "develop": ["sphinx", "sphinx-autobuild", "sphinx_rtd_theme"] },