Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misleading error message when flag name has an underscore #110

Closed
RichardBowenGM opened this issue Feb 21, 2024 · 2 comments
Closed

Misleading error message when flag name has an underscore #110

RichardBowenGM opened this issue Feb 21, 2024 · 2 comments

Comments

@RichardBowenGM
Copy link

Example code:

from cyclopts import App
app = App()

@app.command
def foo(test_flag: bool):
  print("x" if test_flag else "y")

app()

Executing with --test-flag:

$python test.py foo --test_flag
╭─ Error ─────────────────────────────────────────────────────────────────╮
│ Unknown option: "--test-flag".                                          │
╰─────────────────────────────────────────────────────────────────────────╯

The error message seems incorrect, because --test-flag is right and is a known option. Ideally cyclopts should say Unknown option: --test_flag, or maybe test-flag and test_flag should be synonyms.

Version info: cyclopts 2.3.1, python 3.9.18.

@BrianPugh
Copy link
Owner

BrianPugh commented Feb 21, 2024

I'll be trying to pipe through what the CLI-provided token was so that help/error messages can be a bit more specific.

BrianPugh added a commit that referenced this issue Feb 22, 2024
Introduce UnknownOptionError.
BREAKING: Change negative-flag-assignment-exception from ValidationError to generic CycloptsError.
BREAKING: Change exception for unknown option token from ValidationError to UnknownOptionError.
@BrianPugh
Copy link
Owner

This has been addressed in the newly released v2.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants