mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2025-07-24 04:50:34 -04:00
Eliminate a few Any
s in LruCache
type hints (#11453)
This commit is contained in:
parent
432a174bc1
commit
5a0b652d36
4 changed files with 32 additions and 19 deletions
|
@ -22,6 +22,7 @@ from typing import (
|
|||
Iterable,
|
||||
MutableMapping,
|
||||
Optional,
|
||||
Sized,
|
||||
TypeVar,
|
||||
Union,
|
||||
cast,
|
||||
|
@ -104,7 +105,13 @@ class DeferredCache(Generic[KT, VT]):
|
|||
max_size=max_entries,
|
||||
cache_name=name,
|
||||
cache_type=cache_type,
|
||||
size_callback=(lambda d: len(d) or 1) if iterable else None,
|
||||
size_callback=(
|
||||
(lambda d: len(cast(Sized, d)) or 1)
|
||||
# Argument 1 to "len" has incompatible type "VT"; expected "Sized"
|
||||
# We trust that `VT` is `Sized` when `iterable` is `True`
|
||||
if iterable
|
||||
else None
|
||||
),
|
||||
metrics_collection_callback=metrics_cb,
|
||||
apply_cache_factor_from_config=apply_cache_factor_from_config,
|
||||
prune_unread_entries=prune_unread_entries,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue