typing 是在 python 3.5 才有的模块
Python 类型提示:https://cloud.tencent.com/developer/article/1864619
https://cloud.tencent.com/developer/article/1866298
https://www.cnblogs.com/poloyy/p/15153883.html
https://cloud.tencent.com/developer/article/1866296
https://cloud.tencent.com/developer/article/1866297
https://cloud.tencent.com/developer/article/1866293
https://cloud.tencent.com/developer/article/1866294
https://cloud.tencent.com/developer/article/1867496
可选类型
# 可选参数
def foo(arg: int = 0) -> None:
...
# 不传 arg 默认取 0
foo()
def foo_func(arg: Optional[int] = None):
print(arg)
foo_func()
foo_func(1)
# 输出结果
None
1
def foo_func(arg: int = None):
print(arg)
foo_func()
foo_func(1)
# 输出结果
None
1
这种写法,Pycharm 并不会 warning