Skip to content

Commit 98eb435

Browse files
committed
Add invalid choice handling to convert choice
1 parent c473d0a commit 98eb435

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
55

66
## [Unreleased]
7+
### Fixed
8+
- Add invalid choice handling to `convert_choice`.
79

810
## [1.0.16] - 2024-12-30
911
### Fixed

src/rra_tools/cli_tools/options.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ def convert_choice(value: str, choices: Collection[str]) -> list[str]:
3030
"""
3131
if value == RUN_ALL:
3232
return list(choices)
33-
return [value]
33+
elif value in choices:
34+
return [value]
35+
else:
36+
msg = f"Invalid choice: {value}. Must be one of {choices} or {RUN_ALL}."
37+
raise ValueError(msg)
3438

3539

3640
def process_choices(

0 commit comments

Comments
 (0)