Skip to main content

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 [ ]
  • 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 typer_dataclass 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

typerx-0.1.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

typerx-0.1.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file typerx-0.1.0.tar.gz.

File metadata

  • Download URL: typerx-0.1.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.17.1 CPython/3.12.4 Darwin/24.0.0

File hashes

Hashes for typerx-0.1.0.tar.gz
Algorithm Hash digest
SHA256 34ef6a6646abfd14d79e1c3180e4dd4d2454f0e1e50470525c8a33ef96da6d29
MD5 0a1bb79c05b2f9817b349903c091c9c7
BLAKE2b-256 766f13b8a4cb5718135fbc7444d8e88f4c3fa07c7de089c67d190c591269cf42

See more details on using hashes here.

File details

Details for the file typerx-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: typerx-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.17.1 CPython/3.12.4 Darwin/24.0.0

File hashes

Hashes for typerx-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 36ceef4bab04610e077b14764868a938a9b6144f533aee92faa64c864547bd07
MD5 3d785491b7c81703025aeff8e7c4007f
BLAKE2b-256 a9bbbd303e174647831ae5bb8a69b2f0614ee83c986600a8613adc1ac1cb83b0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page