Skip to content

Commit ff8bbc8

Browse files
committed
Hastily attempt to patch NoneTypes appearing (jstrieb#7)
1 parent 453264e commit ff8bbc8

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

github_stats.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,20 @@ async def query(self, generated_query: str) -> Dict:
4040
r = await self.session.post("https://api.github.com/graphql",
4141
headers=headers,
4242
json={"query": generated_query})
43-
return await r.json()
43+
result = await r.json()
44+
if result is not None:
45+
return result
4446
except:
4547
print("aiohttp failed for GraphQL query")
4648
# Fall back on non-async requests
4749
async with self.semaphore:
4850
r = requests.post("https://api.github.com/graphql",
4951
headers=headers,
5052
json={"query": generated_query})
51-
return r.json()
53+
result = r.json()
54+
if result is not None:
55+
return result
56+
return dict()
5257

5358
async def query_rest(self, path: str, params: Optional[Dict] = None) -> Dict:
5459
"""
@@ -312,6 +317,8 @@ async def get_stats(self) -> None:
312317
repos += contrib_repos.get("nodes", [])
313318

314319
for repo in repos:
320+
if repo is None:
321+
continue
315322
name = repo.get("nameWithOwner")
316323
if name in self._repos or name in self._exclude_repos:
317324
continue

0 commit comments

Comments
 (0)