From 284ce967fba9e307804d89cfa2b6c10802767728 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Thu, 19 May 2022 19:19:15 -0500 Subject: [PATCH] typing Literal fallback --- adafruit_rsa/_compat.py | 8 +++++++- adafruit_rsa/key.py | 7 ++++++- adafruit_rsa/machine_size.py | 7 ++++++- adafruit_rsa/pkcs1.py | 7 ++++++- adafruit_rsa/prime.py | 5 ++++- 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/adafruit_rsa/_compat.py b/adafruit_rsa/_compat.py index 09eec3f..b0e613a 100755 --- a/adafruit_rsa/_compat.py +++ b/adafruit_rsa/_compat.py @@ -14,10 +14,16 @@ from struct import pack try: - from typing import Any, Literal, Tuple + from typing import Any, Tuple + + try: + from typing import Literal + except ImportError: + from typing_extensions import Literal except ImportError: pass + __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RSA.git" diff --git a/adafruit_rsa/key.py b/adafruit_rsa/key.py index 6770f59..8cb3bc1 100755 --- a/adafruit_rsa/key.py +++ b/adafruit_rsa/key.py @@ -35,7 +35,12 @@ import adafruit_rsa.core try: - from typing import Any, Tuple, Dict, Callable, Literal + from typing import Any, Tuple, Dict, Callable + + try: + from typing import Literal + except ImportError: + from typing_extensions import Literal except ImportError: pass diff --git a/adafruit_rsa/machine_size.py b/adafruit_rsa/machine_size.py index e12dda6..caad2cc 100755 --- a/adafruit_rsa/machine_size.py +++ b/adafruit_rsa/machine_size.py @@ -13,7 +13,12 @@ import sys try: - from typing import Literal, Tuple + from typing import Tuple + + try: + from typing import Literal + except ImportError: + from typing_extensions import Literal except ImportError: pass diff --git a/adafruit_rsa/pkcs1.py b/adafruit_rsa/pkcs1.py index 28041ee..db0bb21 100755 --- a/adafruit_rsa/pkcs1.py +++ b/adafruit_rsa/pkcs1.py @@ -26,7 +26,7 @@ from adafruit_rsa import common, transform, core try: - from typing import Optional, Iterator, Union, Literal + from typing import Optional, Iterator, Union from adafruit_rsa.key import PublicKey, PrivateKey try: @@ -34,6 +34,11 @@ except ImportError: from typing_extensions import Protocol + try: + from typing import Literal + except ImportError: + from typing_extensions import Literal + class _FileLikeObject(Protocol): """A file like object that implements the :meth:`read` method""" diff --git a/adafruit_rsa/prime.py b/adafruit_rsa/prime.py index 62aabeb..7ce171f 100755 --- a/adafruit_rsa/prime.py +++ b/adafruit_rsa/prime.py @@ -17,7 +17,10 @@ import adafruit_rsa.randnum try: - from typing import Literal + try: + from typing import Literal + except ImportError: + from typing_extensions import Literal except ImportError: pass