mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-03 07:34:48 -04:00
Fix new flake8 errors (#7470)
This commit is contained in:
parent
8c8858e124
commit
1a1da60ad2
7 changed files with 19 additions and 12 deletions
|
@ -15,7 +15,7 @@
|
|||
|
||||
import logging
|
||||
from collections import namedtuple
|
||||
from typing import Callable, List
|
||||
from typing import Callable, Iterable, List, TypeVar
|
||||
|
||||
from prometheus_client import Counter
|
||||
|
||||
|
@ -42,12 +42,14 @@ users_woken_by_stream_counter = Counter(
|
|||
"synapse_notifier_users_woken_by_stream", "", ["stream"]
|
||||
)
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
|
||||
# TODO(paul): Should be shared somewhere
|
||||
def count(func, l):
|
||||
"""Return the number of items in l for which func returns true."""
|
||||
def count(func: Callable[[T], bool], it: Iterable[T]) -> int:
|
||||
"""Return the number of items in it for which func returns true."""
|
||||
n = 0
|
||||
for x in l:
|
||||
for x in it:
|
||||
if func(x):
|
||||
n += 1
|
||||
return n
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue