[sso-admin] Add cache decorator for python 3.7
parent
7bf216ef69
commit
da52d322af
|
@ -37,7 +37,7 @@ import stat
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Dict, List, Optional, Union
|
from typing import Any, Callable, Dict, List, Optional, Union
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from attr import field, frozen
|
from attr import field, frozen
|
||||||
|
@ -52,10 +52,15 @@ from jose.backends.rsa_backend import RSAKey
|
||||||
from jose.constants import ALGORITHMS
|
from jose.constants import ALGORITHMS
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Python 3.8
|
|
||||||
from functools import cached_property as cache
|
|
||||||
except ImportError:
|
|
||||||
from functools import cache # type: ignore # Python 3.9+
|
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]
|
Data = Union[str, bytes]
|
||||||
|
|
Loading…
Reference in New Issue