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.3.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.3-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: typerx-0.1.3.tar.gz
  • Upload date:
  • Size: 4.1 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

Hashes for typerx-0.1.3.tar.gz
Algorithm Hash digest
SHA256 406177ae98c88b0016405b2017e72bf04e1f84a104a6910167471d017d4f5175
MD5 62b6d72f754b364f24c615f48bf084d7
BLAKE2b-256 5debb88a2eaefb9df975e7e6d005bb8b1d66bc71d9e149346cdbbb90c2180f9b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typerx-0.1.3-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

Hashes for typerx-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 037935a40aa40d1308a3207cbe78bfc5113f4655924239d6c912f161d8445b03
MD5 fd7e89a4d80eead5500ee504c3d3ece0
BLAKE2b-256 33ada1633cc2f96cf19ee110ddaf15ecca27aafe3774e88df8a9594eccf58507

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