Skip to content

Commit 3f40766

Browse files
committed
Include enum members in error when invalid value is given (pytorch-lightning#17247).
1 parent ccb6ef7 commit 3f40766

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

CHANGELOG.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ Changed
1919
^^^^^^^
2020
- Switched from ``setup.cfg`` to ``pyproject.toml`` for configuration.
2121
- Removed ``build_sphinx`` from ``setup.py`` and documented how to build.
22+
- Include enum members in error when invalid value is given
23+
`pytorch-lightning#17247
24+
<https://github.com/Lightning-AI/lightning/issues/17247>`__.
2225

2326

2427
v4.20.1 (2023-03-30)

jsonargparse/typehints.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,12 +611,12 @@ def adapt_typehints(
611611
val = val.name
612612
else:
613613
if val not in typehint.__members__:
614-
raise_unexpected_value(f'Expected a member of {typehint}', val)
614+
raise_unexpected_value(f'Expected a member of {typehint}: {iter_to_set_str(typehint.__members__)}', val)
615615
elif not serialize and not isinstance(val, typehint):
616616
try:
617617
val = typehint[val]
618618
except KeyError as ex:
619-
raise_unexpected_value(f'Expected a member of {typehint}', val, ex)
619+
raise_unexpected_value(f'Expected a member of {typehint}: {iter_to_set_str(typehint.__members__)}', val, ex)
620620

621621
# Type
622622
elif typehint in {Type, type} or typehint_origin in {Type, type}:

0 commit comments

Comments
 (0)