[sso-admin] Add cache decorator for python 3.7

merge-requests/7/head
Evilham 2022-08-01 12:56:50 +02:00
parent 7bf216ef69
commit da52d322af
No known key found for this signature in database
GPG Key ID: AE3EE30D970886BF
1 changed files with 9 additions and 4 deletions

View File

@ -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]