📦 typepeek
typepeek is a lightweight Python package that infers accurate, human-readable type hints from runtime data — including nested and complex containers like lists, dictionaries, tuples, sets, and even third-party objects like PyTorch tensors.
🚀 Quick Start
Installation
pip install typepeek
Example Usage
from typepeek import infer_type
import torch
data = [torch.tensor(1), torch.tensor(2), 3]
print(infer_type(data))
# Output: List[Union[torch.Tensor, int]]
print(infer_type(data, agnostic=False))
#typing.List[torch.Tensor, torch.Tensor, int]
✨ Features
- ✅ Precise Type Inference — Accurately infers human-readable type hints from runtime values
- 🔁 Deep Nested Structure Support — Handles arbitrarily nested containers (e.g.,
List[Dict[str, Tuple[int, float]]]) - 🧹 Third-Party Object Compatibility — Understands common libraries like
torch.Tensor,np.ndarray, and more - 🔄 Ordered and Unordered Type Support — Handles both ordered collections (e.g.,
List[int, float, str, int]) and unordered collections (e.g.,List[Union[int, float, str]]).
📚 Examples
infer_type([1, 2, 3])
# typing.List[int]
infer_type(["a", 1, 3.14])
# typing.List[typing.Union[str, int, float]]
infer_type({"name": "Alice", "age": 30})
# typing.Dict[str, Union[str, int]]
infer_type((1, "hello", 3.5), agnostic=False)
#typing.Tuple[int, str, float]
infer_type([[1, 2], [3, 4]])
# typing.List[typing.List[int]]
infer_type([torch.tensor(1), np.array(2)], agnostic=False)
#typing.List[torch.Tensor, numpy.ndarray]
🛠 Use Cases
- 📦 Auto-generate type hints for untyped or runtime-generated data
- 🧪 Write better tests for dynamic outputs
- 🧠 Debug and inspect complex runtime object structures
🙌 Contributing
Contributions are welcome! If you have an idea, bug, or feature request, feel free to open an issue or submit a pull request.
📄 License
This project is licensed under the MIT License. See the LICENSE file for details.
👤 Author
👨💻 Le Hoang Viet
🐙 GitHub: Mikyx-1
Metadata
Release files for typepeek 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| typepeek-0.3.0.tar.gz | 5.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| typepeek-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.3 kB
Release files / typepeek-0.3.0.tar.gz
| Download URL | typepeek-0.3.0.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
64d2b3f9a31f90479a378cf76cdec6ce978a1861a57917c9f3215c5a988ed937
|
|
BLAKE2b-256 checksum How to use checksums |
39608fc85eab83d6c0c3df60448bfcadef1d76fbf2757b419e85d865e3256c6c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.11
|
Release files / typepeek-0.3.0-py3-none-any.whl
| Download URL | typepeek-0.3.0-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bd0d09a2b518abebafa87d47a670f3a92151e465da892b1099c39faf805a6de9
|
|
BLAKE2b-256 checksum How to use checksums |
c2d8323aa6a4fac7ff68df70b64de065a41572d9a8ddcfd078d67c4fe14ae6b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.11
|