Compare commits

...

2 Commits

Author SHA1 Message Date
Andrew Morgan 905c83352d Add some mypy ignores 2020-04-06 17:52:38 +01:00
Andrew Morgan fec13bedd6 Fix lint 2020-04-06 17:43:05 +01:00
1 changed files with 6 additions and 6 deletions

View File

@ -22,7 +22,7 @@ _CACHES = {}
_CACHE_PREFIX = "SYNAPSE_CACHE_FACTOR"
# Wrap all global vars into a single object to eliminate `global` calls
CACHE_PROPERTIES: Dict[str, Union[str, float, Optional[Callable[[], None]]]] = {
CACHE_PROPERTIES = {
"prefix": _CACHE_PREFIX,
"default_size_factor": float(os.environ.get(_CACHE_PREFIX, 0.5)),
# Callback to ensure that all caches are the correct size, registered when the
@ -35,7 +35,7 @@ def add_resizable_cache(cache_name, cache_resize_callback):
_CACHES[cache_name.lower()] = cache_resize_callback
if CACHE_PROPERTIES["ensure_correct_cache_sizing"]:
CACHE_PROPERTIES["ensure_correct_cache_sizing"]()
CACHE_PROPERTIES["ensure_correct_cache_sizing"]() # type: ignore[operator]
class CacheConfig(Config):
@ -88,9 +88,9 @@ class CacheConfig(Config):
# Load cache factors from the environment, but override them with the
# ones in the config file if they exist
individual_factors = {
key[len(CACHE_PROPERTIES["prefix"]) + 1 :].lower(): float(val)
key[len(CACHE_PROPERTIES["prefix"]) + 1 :].lower(): float(val) # type: ignore[arg-type]
for key, val in self._environ.items()
if key.startswith(CACHE_PROPERTIES["prefix"] + "_")
if key.startswith(CACHE_PROPERTIES["prefix"] + "_") # type: ignore[operator]
}
individual_factors_config = cache_config.get("per_cache_factors", {}) or {}
@ -99,7 +99,7 @@ class CacheConfig(Config):
individual_factors.update(individual_factors_config)
self.cache_factors = dict() # type: Dict[str, float]
self.cache_factors = {} # type: Dict[str, float]
for cache, factor in individual_factors.items():
if not isinstance(factor, (int, float)):
@ -115,4 +115,4 @@ class CacheConfig(Config):
callback(new_factor)
CACHE_PROPERTIES["ensure_correct_cache_sizing"] = ensure_cache_sizes
CACHE_PROPERTIES["ensure_correct_cache_sizing"]()
CACHE_PROPERTIES["ensure_correct_cache_sizing"]() # type: ignore[operator]