diff --git a/dd-sso/admin/src/admin/lib/keys.py b/dd-sso/admin/src/admin/lib/keys.py index 076387b..3a56719 100644 --- a/dd-sso/admin/src/admin/lib/keys.py +++ b/dd-sso/admin/src/admin/lib/keys.py @@ -37,7 +37,7 @@ import stat from copy import deepcopy from datetime import datetime, timedelta from pathlib import Path -from typing import Any, Dict, List, Optional, Union +from typing import Any, Callable, Dict, List, Optional, Union import requests from attr import field, frozen @@ -52,10 +52,15 @@ from jose.backends.rsa_backend import RSAKey from jose.constants import ALGORITHMS try: - # Python 3.8 - from functools import cached_property as cache -except ImportError: from functools import cache # type: ignore # Python 3.9+ +except ImportError: + try: + from functools import cached_property as cache # type: ignore # Python 3.8 + except ImportError: + from functools import lru_cache + + def cache(call: Callable) -> property: # type: ignore # Python 3.7 + return property(lru_cache()(call)) Data = Union[str, bytes]