コンテンツにスキップ

[mypy]TypeError: 'type' object is not subscriptable を解決する

事象

Python 3.9 環境で mypy を使うと、次のエラーが出る。

def foo() -> list[int]: # <- ここでエラー 'type' object is not subscriptable
    return [1, 2, 3]

解決方法

Python 3.9.7 まで上げると解決する。 yuji38kwmt 氏の Qiita 記事