From 40fba154c2cacbdaf7a2e622e404b50ed7a8d327 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 25 Oct 2023 16:19:32 -0700 Subject: [PATCH] get-google-credentials: Remove Python 2 compatibility. Signed-off-by: Anders Kaseorg --- .../google/get-google-credentials | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/zulip/integrations/google/get-google-credentials b/zulip/integrations/google/get-google-credentials index e598f0cc..5bd45a3a 100644 --- a/zulip/integrations/google/get-google-credentials +++ b/zulip/integrations/google/get-google-credentials @@ -1,18 +1,11 @@ #!/usr/bin/env python3 +import argparse import os -from typing import Optional from oauth2client import client, tools from oauth2client.file import Storage -try: - import argparse - - flags: Optional[argparse.Namespace] = argparse.ArgumentParser( - parents=[tools.argparser] - ).parse_args() -except ImportError: - flags = None +flags = argparse.ArgumentParser(parents=[tools.argparser]).parse_args() # If modifying these scopes, delete your previously saved credentials # at zulip/bots/gcal/ @@ -43,13 +36,10 @@ def get_credentials() -> client.Credentials: if not credentials or credentials.invalid: flow = client.flow_from_clientsecrets(os.path.join(HOME_DIR, CLIENT_SECRET_FILE), SCOPES) flow.user_agent = APPLICATION_NAME - if flags: - # This attempts to open an authorization page in the default web browser, and asks the user - # to grant the bot access to their data. If the user grants permission, the run_flow() - # function returns new credentials. - credentials = tools.run_flow(flow, store, flags) - else: # Needed only for compatibility with Python 2.6 - credentials = tools.run(flow, store) + # This attempts to open an authorization page in the default web browser, and asks the user + # to grant the bot access to their data. If the user grants permission, the run_flow() + # function returns new credentials. + credentials = tools.run_flow(flow, store, flags) print("Storing credentials to " + credential_path)