enums.parse
enums.parse(option, value, message)
Normalise one option value, raising message when it is not a member.
The enum’s own ValueError names the class rather than the accepted spellings, and the accepted spellings are what a caller needs, so every boundary in cadjoint converts through here with the message its tests (and its users) already know.
Parameters
| option |
type[_Option] |
A string enum from this module. |
required |
| value |
Any |
The user’s spelling — a member, or the plain string. |
required |
| message |
str |
The error text to raise instead of the enum’s own. |
required |
Returns
|
_Option |
The matching member. |
Raises
|
ValueError |
If value is not one of the members. |