(
cls, # type: Type[Enum[_V]]
value, # type: str
)
| 173 | |
| 174 | @classmethod |
| 175 | def for_value( |
| 176 | cls, # type: Type[Enum[_V]] |
| 177 | value, # type: str |
| 178 | ): |
| 179 | # type: (...) -> _V |
| 180 | for v in cls.values(): |
| 181 | if v.value == value: |
| 182 | return v |
| 183 | raise ValueError( |
| 184 | "{!r} of type {} must be one of {}".format( |
| 185 | value, type(value), ", ".join(map(repr, cls.values())) |
| 186 | ) |
| 187 | ) |