diff --git a/github/client.py b/github/client.py index cf0efe9..868147d 100644 --- a/github/client.py +++ b/github/client.py @@ -74,14 +74,14 @@ class GHClient: if username and token: self.username = username - self.token = token - self._auth = aiohttp.BasicAuth(username, token) + self.__token = token + self.__auth = aiohttp.BasicAuth(username, token) else: - self._auth = None + self.__auth = None self.username = None - self.token = None + self.__token = None - self.http = http(headers=custom_headers, auth=self._auth) + self.http = http(headers=custom_headers, auth=self.__auth) self._user_cache = ObjectCache[Any, User](user_cache_size) self._repo_cache = ObjectCache[Any, Repository](repo_cache_size) @@ -109,7 +109,7 @@ class GHClient: raise Exception('HTTP Session doesn\'t exist') from exc def __repr__(self) -> str: - return f'<{self.__class__.__name__} has_auth={bool(self._auth)}>' + return f'<{self.__class__.__name__} has_auth={bool(self.__auth)}>' @overload def check_limits(self, as_dict: Literal[True] = True) -> Dict[str, Union[str, int]]: @@ -167,8 +167,8 @@ class GHClient: """ if self.has_started: raise exceptions.AlreadyStarted - if self._auth: - self.http = await http(auth=self._auth, headers=self._headers) + if self.__auth: + self.http = await http(auth=self.__auth, headers=self._headers) try: await self.http.get_self() except exceptions.InvalidToken as exc: @@ -213,7 +213,7 @@ class GHClient: # @_cache(type='User') async def get_self(self) -> User: """:class:`User`: Returns the authenticated User object.""" - if self._auth: + if self.__auth: return User(await self.http.get_self(), self.http) else: raise exceptions.NoAuthProvided diff --git a/github/exceptions.py b/github/exceptions.py index 2399812..cf5dc0c 100644 --- a/github/exceptions.py +++ b/github/exceptions.py @@ -93,8 +93,8 @@ class InvalidToken(ClientException): class InvalidAuthCombination(ClientException): """Raised when the username and token are both provided.""" - def __init__(self): - msg = 'The username and token cannot be used together.' + def __init__(self, msg: str): + #msg = 'The username and token cannot be used together.' super().__init__(msg) diff --git a/github/objects.py b/github/objects.py index 9d2fcb2..2079ed1 100644 --- a/github/objects.py +++ b/github/objects.py @@ -253,6 +253,10 @@ class Repository(APIObject): def forks(self) -> int: return self._response.get('forks') + async def delete(self) -> None: + """Deletes the repository.""" + return await self._http.delete_repo(self.owner.name, self.name,) #type: ignore + class Issue(APIObject): """Representation of an issue on Github.