Fix typing

pull/6391/head
Andrew Morgan 2020-04-03 18:42:05 +01:00
parent cc1dd98362
commit de2565959f
1 changed files with 3 additions and 2 deletions

View File

@ -14,7 +14,7 @@
# limitations under the License. # limitations under the License.
import os import os
from typing import Dict from typing import Callable, Dict, Optional, Union
from ._base import Config, ConfigError from ._base import Config, ConfigError
@ -22,7 +22,7 @@ _CACHES = {}
_CACHE_PREFIX = "SYNAPSE_CACHE_FACTOR" _CACHE_PREFIX = "SYNAPSE_CACHE_FACTOR"
# Wrap all global vars into a single object to eliminate `global` calls # Wrap all global vars into a single object to eliminate `global` calls
CACHE_PROPERTIES = { CACHE_PROPERTIES: Dict[str, Union[str, float, Optional[Callable[[], None]]]] = {
"prefix": _CACHE_PREFIX, "prefix": _CACHE_PREFIX,
"default_size_factor": float(os.environ.get(_CACHE_PREFIX, 0.5)), "default_size_factor": float(os.environ.get(_CACHE_PREFIX, 0.5)),
# Callback to ensure that all caches are the correct size, registered when the # Callback to ensure that all caches are the correct size, registered when the
@ -33,6 +33,7 @@ CACHE_PROPERTIES = {
def add_resizable_cache(cache_name, cache_resize_callback): def add_resizable_cache(cache_name, cache_resize_callback):
_CACHES[cache_name.lower()] = cache_resize_callback _CACHES[cache_name.lower()] = cache_resize_callback
if CACHE_PROPERTIES["ensure_correct_cache_sizing"]: if CACHE_PROPERTIES["ensure_correct_cache_sizing"]:
CACHE_PROPERTIES["ensure_correct_cache_sizing"]() CACHE_PROPERTIES["ensure_correct_cache_sizing"]()