From 11df4ec6c2178bdd25652644a94c213c3064d693 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Thu, 31 Mar 2022 13:38:09 -0400 Subject: Add more type hints to the main state store. (#12267) --- synapse/util/caches/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'synapse/util/caches/__init__.py') 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 -- cgit 1.4.1