@@ -88,60 +88,45 @@ async def getitem(self, resource: str, default: Any = None) -> Any:
88
88
@github_cached
89
89
@validate_github_name ('user' )
90
90
async def get_user_repos (self , user : GitHubUser ) -> Optional [list [dict ]]:
91
- return list (r for r in await self .getitem (f'/users/{ user } /repos' ) if r ['private' ] is False )
91
+ return list (r for r in await self .getitem (f'/users/{ user } /repos' , [] ) if r ['private' ] is False )
92
92
93
93
@github_cached
94
94
@validate_github_name ('org' )
95
95
async def get_org (self , org : GitHubOrganization ) -> Optional [dict ]:
96
- try :
97
- return await self .gh .getitem (f'/orgs/{ org } ' )
98
- except BadRequest :
99
- return None
96
+ return await self .getitem (f'/orgs/{ org } ' )
100
97
101
98
@github_cached
102
99
@validate_github_name ('org' , default = [])
103
100
async def get_org_repos (self , org : GitHubOrganization ) -> list [dict ]:
104
- try :
105
- res = list (r for r in await self .gh .getitem (f'/orgs/{ org } /repos' ) if r ['private' ] is False )
106
- return res
107
- except BadRequest :
108
- return []
101
+ return list (r for r in await self .getitem (f'/orgs/{ org } /repos' , []) if r ['private' ] is False )
109
102
110
103
@normalize_repository
111
104
async def get_repo_files (self , repo : GitHubRepository ) -> list [dict ]:
112
105
if repo .count ('/' ) != 1 :
113
106
return []
114
- try :
115
- return await self .gh .getitem (f'/repos/{ repo } /contents' )
116
- except BadRequest :
117
- return []
107
+ return await self .getitem (f'/repos/{ repo } /contents' , [])
118
108
119
109
@normalize_repository
120
110
async def get_tree_file (self , repo : GitHubRepository , path : str ) -> dict | list | None :
121
111
if repo .count ('/' ) != 1 :
122
112
return None
123
113
if path [0 ] == '/' :
124
114
path = path [1 :]
125
- try :
126
- return await self .gh .getitem (f'/repos/{ repo } /contents/{ path } ' )
127
- except BadRequest :
128
- return None
115
+ return await self .getitem (f'/repos/{ repo } /contents/{ path } ' )
129
116
130
117
@github_cached
131
118
@validate_github_name ('user' , default = [])
132
119
async def get_user_orgs (self , user : GitHubUser ) -> list [dict ]:
133
- try :
134
- return list (await self .gh .getitem (f'/users/{ user } /orgs' ))
135
- except BadRequest :
136
- return []
120
+ return await self .getitem (f'/users/{ user } /orgs' , [])
137
121
138
122
@github_cached
139
123
@validate_github_name ('org' , default = [])
140
124
async def get_org_members (self , org : GitHubOrganization ) -> list [dict ]:
141
- try :
142
- return list (await self .gh .getitem (f'/orgs/{ org } /public_members' ))
143
- except BadRequest :
144
- return []
125
+ return await self .getitem (f'/orgs/{ org } /public_members' , [])
126
+
127
+ @github_cached
128
+ async def get_gist (self , gist_id : str ) -> Optional [dict ]:
129
+ return await self .getitem (f'/gists/{ gist_id } ' )
145
130
146
131
@github_cached
147
132
@validate_github_name ('user' )
@@ -153,13 +138,6 @@ async def get_user_gists(self, user: GitHubUser):
153
138
154
139
return data ['user' ]
155
140
156
- @github_cached
157
- async def get_gist (self , gist_id : str ) -> Optional [dict ]:
158
- try :
159
- return dict (await self .gh .getitem (f'/gists/{ gist_id } ' ))
160
- except BadRequest :
161
- return None
162
-
163
141
@normalize_repository
164
142
async def get_latest_commit (self , repo : GitHubRepository ) -> Optional [dict ] | Literal [False ]:
165
143
split : list = repo .split ('/' )
0 commit comments