typepyPython 变量类型检查器

联合创作 · 2023-09-28 10:03

typepy 是一个 Python 库,用于运行时的变量类型检查器/验证器/转换器。

特征

  • 检查值的类型
  • 验证类型的值
  • 将值从一种类型转换为另一种类型

Python 类型和typepy类的对应关系如下:

支持的类型

Python 类型 typepy:类型类
bool Bool
datetime DateTime
dict Dictionary
float/decimal.Decimal (not infinity/NaN) RealNumber
float/decimal.Decimal (infinity) Infinity
float/decimal.Decimal (NaN) Nan
int Integer
list List
None None
str (not null) String
str (null) NullString
str (IP address) IpAddress

安装

安装:pip

pip install typepy

如果使用typepy.DateTime类,请使用以下命令安装其他依赖包

pip install typepy[datetime]

安装:conda

conda install -c conda-forge typepy

安装: apt

sudo add-apt-repository ppa:thombashi/ppa
sudo apt update
sudo apt install python3-typepy

依赖关系

可选依赖

这些软件包可以通过pip install typepy[datetime]以下方式安装:

 

 

浏览 3
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报