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.2.tar.gz (4.1 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.2-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: typerx-0.1.2.tar.gz
  • Upload date:
  • Size: 4.1 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.2.tar.gz
Algorithm Hash digest
SHA256 cef29dc756c2db0ebf6999f607ec1dcd458e3d6bb8979835ab589032d6c23f22
MD5 a8923743c49ae1f5e006f84adc30b6cd
BLAKE2b-256 8e8a6dfa00a1041b0a68ef10b82feae762fd042bae646255be20240ee6724841

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typerx-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 3.9 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cc616a983f48b7b334aae512e9d79a4fb32766d782ee21186fde0968cb1b3c1c
MD5 e18cbce2153b62b49e48b2ce81ee9340
BLAKE2b-256 786c119ea1b5e6cf4d180eb811e09058fe6060b1465f82534cd8fdf8c188dc9a

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