-
-
Notifications
You must be signed in to change notification settings - Fork 104
Closed
Labels
Description
So I use an enum for some configuration and some enums have a _
in the member field like example_a
which shows up in the --help
message. I want to display the enum value example-a
instead. Is there a way to do this?
I tried use_enum_values=True
and to define a __str__
in the enum class, but that doesnt work.
Minimum code to reproduce:
from enum import StrEnum
from pydantic_settings import BaseSettings, SettingsConfigDict
class Example(StrEnum):
example_a = "example-a"
example_b = "example-b"
class Settings(BaseSettings):
example: Example
model_config = SettingsConfigDict(cli_parse_args=True)
if __name__ == "__main__":
settings = Settings()
Current output
python main.py --help
usage: main.py [-h] [--example {example_a,example_b}]
options:
-h, --help show this help message and exit
--example {example_a,example_b}
(required)
Desired output
python main.py --help
usage: main.py [-h] [--example {example_a,example_b}]
options:
-h, --help show this help message and exit
--example {example-a,example-b}
(required)