Validate item and raise a ValueError with valid options if not present.
(cls, item)
| 11 | |
| 12 | @classmethod |
| 13 | def get_value(cls, item): |
| 14 | """Validate item and raise a ValueError with valid options if not present.""" |
| 15 | try: |
| 16 | return cls[item].value |
| 17 | except KeyError: |
| 18 | valid_options = {e.name for e in cls} |
| 19 | raise ValueError( |
| 20 | "'{}' is not a valid option, must be one of '{}'".format( |
| 21 | item, "', '".join(valid_options) |
| 22 | ) |
| 23 | ) |
no outgoing calls
no test coverage detected