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

Uploaded Python 3

File details

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

File metadata

  • Download URL: typerx-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 22807af81cd71c824d1b0c44693eb408e8466e114b8fa847b576f653c7fa7ea5
MD5 8974cd5fb5c54a154560e76e6f8713f5
BLAKE2b-256 57441ba9795c35cf0232b395733257596dc29340cc71f7de4726d66b817bcfce

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typerx-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 efd193624fb2f50fc0b067742fe517897dae37a3bd6eefd47eafe80ce6c22a0a
MD5 c146fabe5403996b05a8e72ad8806ebd
BLAKE2b-256 d97b7c37fb1b12ff04733866a727f1c4e40838e930e29c5eeeb3b106d5dfea57

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