1
Fork 0
mirror of https://github.com/RGBCube/GitHubWrapper synced 2025-05-17 14:35:09 +00:00

Small fixes

This commit is contained in:
VarMonke 2022-05-16 13:54:15 +05:30
parent db9f385801
commit dddc0d410a
3 changed files with 36 additions and 16 deletions

View file

@ -26,7 +26,7 @@ from .cache import ObjectCache
from .http import http from .http import http
from .objects import Gist, Issue, Organization, Repository, User, File from .objects import Gist, Issue, Organization, Repository, User, File
__all__: Tuple[str, ...] = ('GHClient',) __all__: Tuple[str, ...] = ('GHClient', 'Client')
T = TypeVar('T') T = TypeVar('T')
P = ParamSpec('P') P = ParamSpec('P')
@ -40,9 +40,6 @@ class GHClient:
username: Optional[:class:`str`] username: Optional[:class:`str`]
An optional username to be provided along with a token to make authenticated API calls. An optional username to be provided along with a token to make authenticated API calls.
If you provide a username, the token must be provided as well. If you provide a username, the token must be provided as well.
token: Optional[:class:`str`]
An optional token to be provided along with a username to make authenticated API calls.
If you provide a token, the username must be provided as well.
user_cache_size: Optional[:class:`int`] user_cache_size: Optional[:class:`int`]
Determines the maximum number of User objects that will be cached in memory. Determines the maximum number of User objects that will be cached in memory.
Defaults to 30, must be between 30 and 0 inclusive. Defaults to 30, must be between 30 and 0 inclusive.
@ -141,7 +138,7 @@ class GHClient:
return self.http.session._rates # type: ignore return self.http.session._rates # type: ignore
async def update_auth(self, username: str, token: str) -> None: async def update_auth(self, *, username: str, token: str) -> None:
"""Allows you to input auth information after instantiating the client. """Allows you to input auth information after instantiating the client.
Parameters Parameters
@ -374,3 +371,8 @@ class GHClient:
async def latency(self) -> float: async def latency(self) -> float:
""":class:`float`: Returns the latency of the client.""" """:class:`float`: Returns the latency of the client."""
return await self.http.latency() return await self.http.latency()
class Client(GHClient):
pass

View file

@ -7,22 +7,26 @@ from aiohttp import ClientResponse
__all__: Tuple[str, ...] = ( __all__: Tuple[str, ...] = (
'APIError', 'APIError',
'HTTPException', 'AlreadyStarted',
'ClientException', 'ClientException',
'ResourceNotFound', 'ClientResponse',
'Ratelimited', 'GistNotFound',
'WillExceedRatelimit', 'HTTPException',
'NoAuthProvided',
'InvalidAuthCombination', 'InvalidAuthCombination',
'InvalidToken', 'InvalidToken',
'LoginFailure',
'NotStarted',
'AlreadyStarted',
'UserNotFound',
'RepositoryNotFound',
'IssueNotFound', 'IssueNotFound',
'LoginFailure',
'MissingPermissions',
'NoAuthProvided',
'NotStarted',
'OrganizationNotFound', 'OrganizationNotFound',
'Ratelimited',
'RepositoryAlreadyExists', 'RepositoryAlreadyExists',
'RepositoryNotFound',
'ResourceAlreadyExists',
'ResourceNotFound',
'UserNotFound',
'WillExceedRatelimit',
) )

View file

@ -256,10 +256,12 @@ class Repository(APIObject):
@property @property
def open_issues(self) -> int: def open_issues(self) -> int:
""":class:`int`: The number of open issues on the repository."""
return self._response.get('open_issues') return self._response.get('open_issues')
@property @property
def forks(self) -> int: def forks(self) -> int:
""":class:`int`: The number of forks of the repository."""
return self._response.get('forks') return self._response.get('forks')
@property @property
@ -275,7 +277,15 @@ class Repository(APIObject):
) # type: ignore ) # type: ignore
async def add_file(self, filename: str, message: str, content: str, branch: Optional[str] = None) -> None: async def add_file(self, filename: str, message: str, content: str, branch: Optional[str] = None) -> None:
"""Adds a file to the repository.""" """Adds a file to the repository.
Parameters
----------
filename: :class:`str` The name of the file.
message: :class:`str` The commit message.
content: :class:`str` The content of the file.
branch: :class:`str` The branch to add the file to, defaults to the default branch.
"""
if branch is None: if branch is None:
branch = self.default_branch branch = self.default_branch
@ -450,6 +460,10 @@ class Gist(APIObject):
"""TODO: document this.""" """TODO: document this."""
return self._response return self._response
async def delete(self):
"""Delete the gist."""
await self._http.delete_gist(self.id)
# === Organization stuff ===# # === Organization stuff ===#