Skip to content

Commit 96bd60d

Browse files
docs: add docstring for enum parsing
Signed-off-by: Matthew Grigsby <38010437+MatthewGrigsby@users.noreply.github.com>
1 parent 3d5ac5d commit 96bd60d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

cforge/commands/resources/plugins.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ class _CaseInsensitiveEnum(str, Enum):
3939

4040
@classmethod
4141
def _missing_(cls, value: object) -> Optional["_CaseInsensitiveEnum"]:
42+
"""Resolve unknown values by matching enum values case-insensitively.
43+
44+
Typer converts CLI strings into Enum members. Implementing `_missing_`
45+
allows `--mode EnFoRcE` to resolve to `PluginMode.ENFORCE`, while still
46+
rejecting unknown values.
47+
"""
4248
if not isinstance(value, str):
4349
return None
4450
value_folded = value.casefold()

0 commit comments

Comments
 (0)