summary refs log tree commit diff
path: root/synapse/util/caches
diff options
context:
space:
mode:
authorPatrick Cloke <clokep@users.noreply.github.com>2022-03-31 13:38:09 -0400
committerGitHub <noreply@github.com>2022-03-31 13:38:09 -0400
commit11df4ec6c2178bdd25652644a94c213c3064d693 (patch)
treedb481376b838b1593ee698cc59122fc6b23fe1cc /synapse/util/caches
parentAdd a callback to react to 3PID associations (#12302) (diff)
downloadsynapse-11df4ec6c2178bdd25652644a94c213c3064d693.tar.xz
Add more type hints to the main state store. (#12267)
Diffstat (limited to 'synapse/util/caches')
-rw-r--r--synapse/util/caches/__init__.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/synapse/util/caches/__init__.py b/synapse/util/caches/__init__.py
index 1cbc180eda..42f6abb5e1 100644
--- a/synapse/util/caches/__init__.py
+++ b/synapse/util/caches/__init__.py
@@ -17,7 +17,7 @@ import logging
 import typing
 from enum import Enum, auto
 from sys import intern
-from typing import Any, Callable, Dict, List, Optional, Sized
+from typing import Any, Callable, Dict, List, Optional, Sized, TypeVar
 
 import attr
 from prometheus_client.core import Gauge
@@ -195,8 +195,10 @@ KNOWN_KEYS = {
     )
 }
 
+T = TypeVar("T", Optional[str], str)
 
-def intern_string(string: Optional[str]) -> Optional[str]:
+
+def intern_string(string: T) -> T:
     """Takes a (potentially) unicode string and interns it if it's ascii"""
     if string is None:
         return None