Counter.total
was added to mypy in version 0.940. Your code, part f1
and f2
works fine
from collections import Counter
def f1(c: Counter[str]) -> None:
print(c.total())
def f2(c: Counter) -> None:
print(c.total())
c: Counter = Counter()
c.update(["a", "b", "c", "a", "b", "c"])
f1(c)
f2(c)