示例工程 10-type-annotations-mypy

10-type-annotations-mypy/02-mypy-catches/after.py.txt

text · 0.3 KB

"""strict 之后:补齐注解,并修正赋值类型。"""
 
from collections.abc import Iterable
 
 
def total(values: Iterable[int]) -> int:
    result = 0
    for value in values:
        result += value
    return result
 
 
def parse(text: str) -> int:
    return int(text)