Python で デフォルト値とアノテーション(annotation) をつけたいとき
Python の修正を本格的にはじめて flake8 + black + pymy + isort な環境を作ったので小さいコードのプロジェクトからメンテナンスを開始したんですが、早速ぶち当たったw
デフォルト値とアノテーションを書きたい場合は下記のようにするといいらしい
def foo(opts: dict = {}):
pass
print(foo.__annotations__)
Ref: Adding default parameter value with type hint in Python - Stack Overflow