typing.assert_type(val, typ, /) 呼び出しを確認し、val の推論される型が typ でない場合に報告します。
typing.assert_type(val, typ, /)
val
typ
例:
def greet(name: str) -> None: assert_type(name, str) # OK assert_type(name, int) # 型 'int' が必要ですが、'str' が代わりに指定されています