EveryVoiceTTS / EveryVoiceTTS/EveryVoice

CLI user errors should always raise typer.BadParameter

Open
#855 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
45
Forks
4
Avg merge
1d 2h
Merged PRs (30d)
14

Description

Through the EV project, we have these two patterns:

```
if not text and not filelist:
print("You must define either --text or --filelist", file=sys.stderr)
sys.exit(1)
```

and

```
if text and filelist:
raise typer.BadParameter(
"Got arguments for both --text and --filelist."
" You can only synthesize using one of these options"
)
```

The second is preferable because typer handles the error messages better.

Compare:
```
$ uv run everyvoice synthesize text-to-wav --text asdf --filelist /dev/null /dev/null
Got arguments for both --text and --filelist. You can only synthesize using one of these options
```
vs
```
$ uv run everyvoice synthesize text-to-wav --text asdf --filelist /dev/null /dev/null
Usage: everyvoice synthesize text-to-wav [OPTIONS] MODEL_PATH
Try 'everyvoice synthesize text-to-wav -h' for help.
╭─ Error ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Invalid value: Got arguments for both --text and --filelist. You can only synthesize using one of these options │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
```

There are currently 39 instances of `raise typer.BadParameter(...)` and 43 instances of `sys.exit(1)` in the repo, we should use the former consistently for user CLI errors.

Contributor guide

Open the contributing guide

Research direction

Search the repository for the 43 instances of sys.exit(1) and compare them with the existing typer.BadParameter uses, starting with the everyvoice synthesize text-to-wav CLI example. Convert user-input validation errors consistently while preserving exits that are not CLI user errors. Verify the affected CLI commands produce Typer-formatted errors and run the repository's available tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.