From 58fc1b85ac04bef50cf50e7c1d40749a9e862cd0 Mon Sep 17 00:00:00 2001 From: scito Date: Fri, 30 Dec 2022 01:07:39 +0100 Subject: [PATCH] type compatibility for Python < 3.11 --- extract_otp_secret_keys.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/extract_otp_secret_keys.py b/extract_otp_secret_keys.py index 6410054..92fe039 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, Union +from typing import Any, TextIO, TypedDict, Union, List from qrcode import QRCode # type: ignore @@ -81,9 +81,12 @@ except ImportError: # Types Args = argparse.Namespace OtpUrl = str +# PYTHON 3.11: Otp = TypedDict('Otp', {'name': str, 'secret': str, 'issuer': str, 'type': str, 'counter': int | None, 'url': OtpUrl}) Otp = TypedDict('Otp', {'name': str, 'secret': str, 'issuer': str, 'type': str, 'counter': Union[int, None], 'url': OtpUrl}) -Otps = list[Otp] -OtpUrls = list[OtpUrl] +# PYTHON 3.11: Otps = list[Otp] +Otps = List[Otp] +# PYTHON 3.11: OtpUrls = list[OtpUrl] +OtpUrls = List[OtpUrl] # Global variable declaration