Duplicated code in enum.py for EnumCheck UNIQUE and unique decorator

While going through the enum.py file I came across duplicated code for checking the uniqueness of an Enum.
The @unique uses the same as the [Unique ENUM check] (cpython/Lib/enum.py at 5dc8c84d397110f9edfa56793ad8887b1f176d79 · python/cpython · GitHub) @verify(UNIQUE).I think it would be better to refactor the code into a separate utility function, reducing code redundancy.

I think this is less an idea, and something you could code up and submit as a pull request. (I saw the SO question and your answer, and was thinking that verify.__call__ could simply use unique as the utility function, calling unique(enumeration) and ignoring the return value just so the ValueError could propagate, if raised.)

3 Likes