Giter Club home page Giter Club logo

Comments (4)

BrianPugh avatar BrianPugh commented on August 27, 2024 3

Thanks for opening the issue! This is now supported in v2.9.0

from cyclopts.

BrianPugh avatar BrianPugh commented on August 27, 2024 1

I forgot to update how --help resolves these for choces; this will be resolved in v2.9.1 in just a sec.

from cyclopts.

BrianPugh avatar BrianPugh commented on August 27, 2024 1

Thanks for the additional report! This is due to some inconsistencies in how python internally defines unions. I have a more comprehensive union-check, but I forgot to use it when getting help options! Fix incoming and I'll release 2.9.2.

from cyclopts.

TakWolf avatar TakWolf commented on August 27, 2024

--help seems that there are still issues in v2.9.1

from typing import Literal, TypeAlias

from cyclopts import App

app = App()

FontSingleFormat: TypeAlias = Literal['otf', 'woff2', 'ttf', 'bdf', 'pcf']
FontCollectionFormat: TypeAlias = Literal['otc', 'ttc']


@app.default
def main(
        font_formats: list[FontSingleFormat | FontCollectionFormat] | None = None
):
    print(font_formats)


if __name__ == '__main__':
    app()
(.venv) % python main.py -h
Usage: main COMMAND [ARGS] [OPTIONS]

╭─ Commands ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --help,-h  Display this message and exit.                                                                                                                                                                                                                                                                            │
│ --version  Display application version.                                                                                                                                                                                                                                                                              │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Parameters ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ FONT-FORMATS,--font-formats,--empty-font-formats  [choices: otf,woff2,ttf,bdf,pcf,otc,ttc]                                                                                                                                                                                                                           │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
from typing import Literal

from cyclopts import App

app = App()

type FontSingleFormat = Literal['otf', 'woff2', 'ttf', 'bdf', 'pcf']
type FontCollectionFormat = Literal['otc', 'ttc']


@app.default
def main(
        font_formats: list[FontSingleFormat | FontCollectionFormat] | None = None
):
    print(font_formats)


if __name__ == '__main__':
    app()
(.venv) % python main.py -h
Usage: main COMMAND [ARGS] [OPTIONS]

╭─ Commands ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --help,-h  Display this message and exit.                                                                                                                                                                                                                                                                            │
│ --version  Display application version.                                                                                                                                                                                                                                                                              │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Parameters ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ FONT-FORMATS,--font-formats,--empty-font-formats                                                                                                                                                                                                                                                                     │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

from cyclopts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.