"関数名" は値を返しません。
エラー例
戻り値が None の関数を呼び出し、結果を変数に代入しています。def retNone() -> None:
return None
# "関数名" does not return a value
ret = retNone()
解決方法1 変数への結果代入を削除
関数の戻り値を変数に代入するのをやめます。def retNone() -> None:
return None
# 「ret =」 を削除
retNone()
解決方法2 関数の戻り値型を変更する
関数の戻り値型に誤って None を指定している場合、正しい型に修正します。# 「-> None:」 をへ「-> int:」変更
def retNone() -> int:
return 1
ret = retNone()
検証環境
- Python 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
- mypy 0.790
- Visual Studio Code Version 1.51.1 (user setup)
- Visual Studio Code Extension - Python 2020.11.371526539
- Visual Studio Code Extension - Pylance 2020.11.2
- Microsoft Windows 10 Pro Version 1909 OS Build 18363.1198