diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2022-03-31 13:38:09 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-31 13:38:09 -0400 |
commit | 11df4ec6c2178bdd25652644a94c213c3064d693 (patch) | |
tree | db481376b838b1593ee698cc59122fc6b23fe1cc /synapse/util/caches/__init__.py | |
parent | Add a callback to react to 3PID associations (#12302) (diff) | |
download | synapse-11df4ec6c2178bdd25652644a94c213c3064d693.tar.xz |
Add more type hints to the main state store. (#12267)
Diffstat (limited to 'synapse/util/caches/__init__.py')
-rw-r--r-- | synapse/util/caches/__init__.py | 6 |
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 |