Skip to content

Commit

Permalink
Hastily attempt to patch NoneTypes appearing (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
jstrieb committed Feb 9, 2021
1 parent 453264e commit ff8bbc8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions github_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,20 @@ async def query(self, generated_query: str) -> Dict:
r = await self.session.post("https://api.github.com/graphql",
headers=headers,
json={"query": generated_query})
return await r.json()
result = await r.json()
if result is not None:
return result
except:
print("aiohttp failed for GraphQL query")
# Fall back on non-async requests
async with self.semaphore:
r = requests.post("https://api.github.com/graphql",
headers=headers,
json={"query": generated_query})
return r.json()
result = r.json()
if result is not None:
return result
return dict()

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

for repo in repos:
if repo is None:
continue
name = repo.get("nameWithOwner")
if name in self._repos or name in self._exclude_repos:
continue
Expand Down

0 comments on commit ff8bbc8

Please sign in to comment.