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 [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

typerx-0.1.5.tar.gz (5.8 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.5-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: typerx-0.1.5.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for typerx-0.1.5.tar.gz
Algorithm Hash digest
SHA256 8799b3ee9056841d38b787c7b0a611d059282a8fbaf1ac5e286c172860b82f20
MD5 ac035ce992e5879064768653058eccb5
BLAKE2b-256 1bcc3ed54eac72ddfbc533afe3a909b96253839246d31cf44fd173a0b1bcccd4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typerx-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for typerx-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5c6a2fa06788eac280ef263e4e81d03614b70310b9b73c72fb18ccf3abcbcf1c
MD5 d1d01805dbdd51a723b81ec7a40c8018
BLAKE2b-256 c533c0207ee6d1cc778460b6b77c89c9c56c715e1e93e38c64df155bc04f0fc9

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