From fab48d4a43e35f051f6fa44e70e659bfcdc081cb Mon Sep 17 00:00:00 2001 From: Kun Jinkao <45487685+Snoopy1866@users.noreply.github.com> Date: Wed, 18 Dec 2024 16:54:32 +0800 Subject: [PATCH] fix: raise ArgumentTypeError if `--convert-mode` is invalid --- python/submit/submit.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/submit/submit.py b/python/submit/submit.py index 638af10..2f2a57b 100644 --- a/python/submit/submit.py +++ b/python/submit/submit.py @@ -39,7 +39,10 @@ def __str__(self) -> str: @classmethod def get_from_str(cls, value: str) -> ConvertMode: - return cls[value.upper()] + try: + return cls[value.upper()] + except KeyError: + raise argparse.ArgumentTypeError(f"无效的转换模式:{value}") @classmethod def get_available_values(cls) -> list[ConvertMode]: