From d0924f39d04e7b7128c55a116280e2c6b6ec5a00 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Thu, 21 Apr 2022 20:32:45 +0200 Subject: [PATCH] github: Remove dead code Authentication is handled directly in the session --- swh/lister/github/lister.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/swh/lister/github/lister.py b/swh/lister/github/lister.py index 2e051f1..6bcde00 100644 --- a/swh/lister/github/lister.py +++ b/swh/lister/github/lister.py @@ -75,18 +75,10 @@ class RateLimited(Exception): retry_if_result(lambda r: r.status_code == 502), ), ) -def github_request( - url: str, token: Optional[str] = None, session: Optional[requests.Session] = None -) -> requests.Response: - session = init_session(session) +def github_request(url: str, session: requests.Session) -> requests.Response: + response = session.get(url) - headers = {} - if token: - headers["Authorization"] = f"token {token}" - - response = session.get(url, headers=headers) - - anonymous = token is None and "Authorization" not in session.headers + anonymous = "Authorization" not in session.headers if ( # GitHub returns inconsistent status codes between unauthenticated