A lightweight tool that helps you convert Python types to TypeScript types
Project description
pytots
一个轻量级的工具,帮助你将Python类型转换为TypeScript类型。
功能特性
- 支持基本Python类型到TypeScript类型的转换
- 支持高级类型(如Union、Optional等)
- 处理循环引用问题
- 支持自定义类型映射
安装
使用uv安装:
uv add pytots
快速开始
from py_ts import convert_to_typescript
# 基本类型转换
result = convert_to_typescript({
'name': str,
'age': int,
'is_active': bool
})
print(result)
# 输出: interface GeneratedInterface {
# name: string;
# age: number;
# is_active: boolean;
# }
示例
查看 py_ts/example/ 目录下的示例文件:
basic_types_example.py- 基本类型转换示例advanced_types_example.py- 高级类型转换示例circular_reference_example.py- 循环引用处理示例
开发
# 安装开发依赖
uv sync --group dev
# 运行测试
pytest
许可证
MIT License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pytots-0.2.0.tar.gz
(7.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytots-0.2.0.tar.gz.
File metadata
- Download URL: pytots-0.2.0.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
caf6b4d7a704397952fde1205dfb5943887649dd47bde76315b378e01fe88cd4
|
|
| MD5 |
7a3b28f058f51926cc972ce9a804d921
|
|
| BLAKE2b-256 |
79b9dabda04ea6da370cc952a703649a29f1eb50f446c8a8bba0f16bc024ddcc
|
File details
Details for the file pytots-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pytots-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a359f0253772ee46d295a02a1331f34427483ca104bf41e6e1ead15a61eaaf6
|
|
| MD5 |
6442b7627a42a537621efdece0807bf8
|
|
| BLAKE2b-256 |
f1fe0989eb00d37f18060acc3255cb5abcdcdea9026d19d8ec5deafefba18732
|