python中typeguard包

https://typeguard.readthedocs.io/en/latest/#

# -*- coding: utf-8 -*-
# @Time    : 2021/3/31 15:06
# @Author  : zhaozhuang
from typeguard import typechecked


# @typechecked
def some_function(a: int, b: float, c: str, *args: str) -> bool:
    res = a - b
    return res


print(some_function(1, 1.2, 'nihao'))

 添加注解之后,直接报错

原文地址:https://www.cnblogs.com/xinmomoyan/p/14601598.html