博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

python中typeguard包

Posted on 2021-03-31 15:15  心默默言  阅读(700)  评论(0)    收藏  举报

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'))

 

 添加注解之后,直接报错