A Typer extension for building complex CLI applications, with dataclass support.
Project description
TyperX
TyperX is a library for extending Typer with features useful in Machine Learning applications, including:
- Basic dataclass type support [x]
- Basic union type support [x]
- Recursive dataclass type support [x]
- pydantic model support [ ]
Installation
Install TyperX using pip:
pip install agentx
Usage Example
Create a file named main.py:
from dataclasses import dataclass
from typing import Union
@dataclass
class Data:
hi: int = 1
ho: Union[int, str] = 1
def main(data: Data):
print(data)
if __name__ == "__main__":
import typer
from typerx import with_dataclass
typer.run(with_dataclass(main))
Run the script and check the help message:
python main.py --help
You should see output similar to this:
Usage: main.py [OPTIONS]
a simple demo
╭─ Options ───────────────────────────────────────────────────────────────────────╮
│ --data.hi INTEGER [default: 1] │
│ --data.ho UNION[INT, STR] [default: 1] │
│ --help Show this message and exit. │
╰─────────────────────────────────────────────────────────────────────────────────╯
Run the script without any options:
python main.py
This will output:
Data(hi=1, ho=1)
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
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 typerx-0.1.4.tar.gz.
File metadata
- Download URL: typerx-0.1.4.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: pdm/2.17.1 CPython/3.10.12 Linux/6.5.0-1023-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0fec655ed3ca9a4f2ef14d25f552826ed34b1c5c1c32a3e13c267d11a07548e1
|
|
| MD5 |
23fc089707a7e32508d4b7278f1c1950
|
|
| BLAKE2b-256 |
6a2ca5a77e636885c5739cee9ba0036660f033b0735ac68b676e25cd7f0ab856
|
File details
Details for the file typerx-0.1.4-py3-none-any.whl.
File metadata
- Download URL: typerx-0.1.4-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: pdm/2.17.1 CPython/3.10.12 Linux/6.5.0-1023-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c8e09624db0744b88eb440d027acaaf4eee5349e1f9c35f741f0ce38ec181dc
|
|
| MD5 |
41aa9eac8fff44f84f9646f96b08f7bf
|
|
| BLAKE2b-256 |
701729b209e5384ef374a1fae51267eabe14206f7fed42e07fd06b9661054f88
|