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.1.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.1.tar.gz.
File metadata
- Download URL: pytots-0.2.1.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 |
8015ae0da77fc7b00db5145fec405bfebb61da03dc50e18b7fe2d8d9f914ee94
|
|
| MD5 |
c895c35d43544455648a2fec0f20c7bd
|
|
| BLAKE2b-256 |
f8c6a3161bfbf1cf215033f935b09b834dbec9b8037041563a8536bfc754d48f
|
File details
Details for the file pytots-0.2.1-py3-none-any.whl.
File metadata
- Download URL: pytots-0.2.1-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 |
cc385fefa009d4c7e6abcd34cf8e52486dc80e3f45b1728807c56849dd48ef1d
|
|
| MD5 |
a6739c19a98351e0defcd61ef98e157f
|
|
| BLAKE2b-256 |
680eb09915761449d8d9abf4d38ac667266af6e6fb36d2c6174d2d0726634c40
|