From a5768ba1e666c3ef90c3fa3d2d74a12b887d05f6 Mon Sep 17 00:00:00 2001 From: scito Date: Thu, 29 Dec 2022 22:34:07 +0100 Subject: [PATCH] Workaround for PYTHON < 3.10: use Union[int, None] instead of int | None --- extract_otp_secret_keys.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/extract_otp_secret_keys.py b/extract_otp_secret_keys.py index ba5e339..711c350 100644 --- a/extract_otp_secret_keys.py +++ b/extract_otp_secret_keys.py @@ -53,7 +53,7 @@ import sys import urllib.parse as urlparse from enum import Enum from operator import add -from typing import Any, TextIO, TypedDict +from typing import Any, TextIO, TypedDict, Union from qrcode import QRCode # type: ignore @@ -79,7 +79,8 @@ except ImportError: # Types Args = argparse.Namespace OtpUrl = str -Otp = TypedDict('Otp', {'name': str, 'secret': str, 'issuer': str, 'type': str, 'counter': int | None, 'url': OtpUrl}) +# Workaround for PYTHON < 3.10: use Union[int, None] instead of int | None +Otp = TypedDict('Otp', {'name': str, 'secret': str, 'issuer': str, 'type': str, 'counter': Union[int, None], 'url': OtpUrl}) Otps = list[Otp] OtpUrls = list[OtpUrl] @@ -360,7 +361,7 @@ def get_payload_from_otp_url(otpauth_migration_url: str, i: int, input_source: s if verbose > 2: print(f"\nDEBUG: parsed_url={parsed_url}") try: params = urlparse.parse_qs(parsed_url.query, strict_parsing=True) - except Exception: # Not necessary for Python >= 3.11 + except Exception: # Necessary for PYTHON < 3.11 params = {} if verbose > 2: print(f"\nDEBUG: querystring params={params}") if 'data' not in params: