-
I'm trying to allow both @dataclass(kw_only=True)
class LogLevelPathOptions:
"""Log level and path options."""
log_level: An[
Literal["TRACE", "DEBUG", "INFO", "SUCCESS", "WARNING", "ERROR", "CRITICAL"],
cappa.Arg(short="-L", long=True, parse=str.upper),
Doc("Log level to use when logging messages."),
] = "INFO" If I read the docs correctly,
How would I go about achieving that? Should I store the literal in a type variable and use |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
mm so There is also parsing-level validation of literals, but as a general pattern With that said, in this scenario, since it doesn't otherwise affect the parsed value, it's just validation on top of it, I could see where it could make sense to avoid checking choices inside the parser at all, and to only do so at the parsing/mapping phase. |
Beta Was this translation helpful? Give feedback.
#179