summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/cache_key.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/sql/cache_key.py')
-rw-r--r--lib/sqlalchemy/sql/cache_key.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/sqlalchemy/sql/cache_key.py b/lib/sqlalchemy/sql/cache_key.py
index 49f1899d5..ff659b77d 100644
--- a/lib/sqlalchemy/sql/cache_key.py
+++ b/lib/sqlalchemy/sql/cache_key.py
@@ -7,10 +7,12 @@
from __future__ import annotations
-from collections import namedtuple
import enum
from itertools import zip_longest
+import typing
+from typing import Any
from typing import Callable
+from typing import NamedTuple
from typing import Union
from .visitors import anon_map
@@ -22,6 +24,10 @@ from ..util import HasMemoized
from ..util.typing import Literal
+if typing.TYPE_CHECKING:
+ from .elements import BindParameter
+
+
class CacheConst(enum.Enum):
NO_CACHE = 0
@@ -345,7 +351,7 @@ class MemoizedHasCacheKey(HasCacheKey, HasMemoized):
return HasCacheKey._generate_cache_key(self)
-class CacheKey(namedtuple("CacheKey", ["key", "bindparams"])):
+class CacheKey(NamedTuple):
"""The key used to identify a SQL statement construct in the
SQL compilation cache.
@@ -355,6 +361,9 @@ class CacheKey(namedtuple("CacheKey", ["key", "bindparams"])):
"""
+ key: Tuple[Any, ...]
+ bindparams: Sequence[BindParameter]
+
def __hash__(self):
"""CacheKey itself is not hashable - hash the .key portion"""