1
Fork 0
mirror of https://github.com/RGBCube/GitHubWrapper synced 2025-05-18 15:05:08 +00:00

Fixing get_repo returning None for license, and erroring

This commit is contained in:
VarMonke 2022-03-29 20:02:12 +05:30
parent 45db6d5120
commit 0fa6f2b0fa
2 changed files with 6 additions and 3 deletions

View file

@ -28,7 +28,7 @@ class Repository(APIOBJECT):
'stargazers_count',
'watchers_count',
'forks',
'license'
'license',
)
def __init__(self, response: dict, session: aiohttp.ClientSession) -> None:
super().__init__(response, session)
@ -47,12 +47,15 @@ class Repository(APIOBJECT):
setattr(self, key, dt_formatter(value))
continue
if 'license' in key and value is None:
setattr(self, key, None)
else:
setattr(self, key, value)
continue
def __repr__(self) -> str:
return f'<Repository; id: {self.id}, name: {self.name}, owner: {self.owner}, updated_at: {self.updated_at}, default_branch: {self.default_branch}, license: {self.license["name"]}>'
return f'<Repository; id: {self.id}, name: {self.name}, owner: {self.owner}, updated_at: {self.updated_at}, default_branch: {self.default_branch}, license: {self.license}>'
@classmethod
async def from_name(cls, session: aiohttp.ClientSession,owner: str, repo_name: str) -> 'Repository':