diff --git a/Github/http.py b/Github/http.py index 4da28e0..740f7a1 100644 --- a/Github/http.py +++ b/Github/http.py @@ -163,10 +163,17 @@ class http: def data(self): #return session headers and auth headers = {**self.session.headers} - auth = {'username': self.auth.login, 'token': self.auth.password} - + if self.auth: + auth = {'username': self.auth.login, 'token': self.auth.password} + auth = None return {'headers': headers, 'auth': auth} + async def latency(self): + """Returns the latency of the current session.""" + start = datetime.utcnow() + await self.session.get(BASE_URL) + return (datetime.utcnow() - start).total_seconds() + async def get_self(self) -> GithubUserData: """Returns the authenticated User's data""" result = await self.session.get(SELF_URL) diff --git a/Github/main.py b/Github/main.py index 80ecb8c..5f6150d 100644 --- a/Github/main.py +++ b/Github/main.py @@ -155,9 +155,8 @@ class GHClient: async def latency(self) -> float: """Returns the latency of the client.""" - start = datetime.utcnow() - await self.http.session.get(BASE_URL + '/zen') - return (datetime.utcnow() - start).total_seconds() + return await self.http.latency() +