Skip to main content

engorgio

Expands function arguments into fields.

https://user-images.githubusercontent.com/22648375/235036031-a9dc6589-e350-4a18-9114-6568cb362f74.mp4

Installation

pypi package to come if this works out, and I can decide what to call it. I think its possible to do this for other objects like dataclasses as well.

pip install git+https://github.com/WaylonWalker/engorgio.gi

Usage

Setup your models.

from typing import Optional

from pydantic import BaseModel, Field


class Alpha(BaseModel):
    a: int


class Color(BaseModel):
    r: int
    g: int
    b: int
    alpha: Alpha


class Hair(BaseModel):
    color: Color
    length: int


class Person(BaseModel):
    name: str
    other_name: Optional[str] = None
    age: int
    email: Optional[str]
    pet: str = "dog"
    address: str = Field("123 Main St", description="Where the person calls home.")
    hair: Hair

Now create a typer command using your models. engorgio will expand all of the typer fields for you.

import typer
from engorgio import engorgio
app = typer.Typer(
    name="engorgio",
    help="a demo app",
)

@app.command()
@engorgio
def get_person(person: Person) -> Person:
    """Get a person's information."""
    from rich import print

    print(person)

Get the help message.

engorgio get-person --help

 Usage: engorgio get-person [OPTIONS]

 Get a person's information.

╭─ Options ──────────────────────────────────────────────────────────────────────────────╮
│ --help          Show this message and exit.                                            │
╰────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Person ───────────────────────────────────────────────────────────────────────────────╮
│ *  --name              TEXT     [default: None] [required]                             │
│    --other-name        TEXT     [default: None]                                        │
│ *  --age               INTEGER  [default: None] [required]                             │
│    --email             TEXT     [default: None]                                        │
│    --pet               TEXT     [default: dog]                                         │
│    --address           TEXT     Where the person calls home. [default: 123 Main St]    │
╰────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Person.Hair ──────────────────────────────────────────────────────────────────────────╮
│ *  --length        INTEGER  [default: None] [required]                                 │
╰────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Person.Hair.Color ────────────────────────────────────────────────────────────────────╮
│ *  --r        INTEGER  [default: None] [required]                                      │
│ *  --g        INTEGER  [default: None] [required]                                      │
│ *  --b        INTEGER  [default: None] [required]                                      │
╰────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Person.Hair.Color.Alpha ──────────────────────────────────────────────────────────────╮
│ *  --a        INTEGER  [default: None] [required]                                      │
╰────────────────────────────────────────────────────────────────────────────────────────╯

Calling the cli will print out a Person object.

engorgio get-person --name me --age 1 --r 1 --g 1 --b 1 --a 1 --length 1

Calling the cli while not specifying required arguments will automatically prompt for them.

engorgio get-person

License

engorgio is distributed under the terms of the MIT license.

Metadata

Release files for engorgio 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for engorgio 0.4.0
File Size Uploaded Provenance Actions
engorgio-0.4.0.tar.gz 17.5 kB Without provenance Details for engorgio-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for engorgio 0.4.0
File Interpreter ABI Platform Actions
engorgio-0.4.0-py3-none-any.whl Python 3 none any Details for engorgio-0.4.0-py3-none-any.whl

Total release size: 25.2 kB

Release files / engorgio-0.4.0.tar.gz

Download URL engorgio-0.4.0.tar.gz
Size 17.5 kB
Tags Source
SHA-256 checksum
How to use checksums
905addeaee65c87e4be4209d771ca8ae2144ca311a9b08bad2b245b699db8177
BLAKE2b-256 checksum
How to use checksums
350f2d206e95e9f046c2765e11a5ded5fde6f2ca97788e276af12b0fbb697f83
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via python-httpx/0.25.0

Release files / engorgio-0.4.0-py3-none-any.whl

Download URL engorgio-0.4.0-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a002fca38cfa32bcc7c4b161a59ab09fce679fb7c99abf936768dfda6a30b2b2
BLAKE2b-256 checksum
How to use checksums
dc0c2b7df5ba8d3e3e9756e17e471c8f0d0381b9f20acc85b7d91826972099e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via python-httpx/0.25.0

Security for engorgio 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page