"""蓝色天空网 mbsky.com | Intentionally invalid typing, for mypy only."""
def combine(first: int, second: int) -> int:
return first + second
wrong_arguments = combine("7", "8")
def wide_record_mean(records: list[dict[str, str | int]]) -> float:
total = 0
for record in records:
total += record["minutes"]
return total / len(records)
本例需在 Python 3.12 和 Mypy 中运行,请复制源码、保存文件或下载工程包后在本地执行验证。
运行说明与环境独立工程
运行环境:Python 3.12 和 Mypy
入口文件:projects/python-lab/python-type-hints-check-bad.py
本地运行步骤快速上手
- 点击上方“保存源码”保存为
python-type-hints-check-bad.py,或下载右侧课程工程包。 - 确认本地已准备 Python 3.12 和 Mypy。
- 按对应章节命令执行,结合正文核对实际输出。
附件与关联工程包下载
课程关联工程包(登记关联82章) · 含当前章节或实例 · mbskycom202611a463.zip
课程关联工程包(登记关联82章) · 含当前章节或实例 · mbskycom202612a292.zip