0xf

日記だよ

python3で関数を返す際はCallableでヒントする

from typing import Callable

def f() -> Callable[[], str]:
    def _() -> str:
        return "hello world"
    return _

r = f()
s = r() # s は str と判定される

typing --- 型ヒントのサポート — Python 3.9.4 ドキュメント