trafaret/Enum: support Python >=3.4 enum module#67
trafaret/Enum: support Python >=3.4 enum module#67spumer wants to merge 3 commits intoDeepwalker:masterfrom
enum module#67Conversation
|
@Deepwalker what do you think? |
trafaret/__init__.py
Outdated
|
|
||
| @classmethod | ||
| def _handle_variants(self, variants): | ||
| if enum is None: |
There was a problem hiding this comment.
Now your code accepts not only either enum.Enum or list of enum values but also a mix of them.
I suspect t.Enum(Colors, Fruits) makes a logical mess.
Thus please make sure that variants is either a tuple with the single enum.Enum element or it doesn't contain enum.Enum items at all.
Otherwise TypeError should be raised.
There was a problem hiding this comment.
Also inline _handle_variants into constructor.
There is no need for extra method if this method is called only once. It just pollutes class namespace.
trafaret/__init__.py
Outdated
|
|
||
| @classmethod | ||
| def _handle_variants(self, variants): | ||
| if enum is None: |
There was a problem hiding this comment.
Also inline _handle_variants into constructor.
There is no need for extra method if this method is called only once. It just pollutes class namespace.
|
Not sure about your keys not values approach. What do you want to check after all? |
Fix #60 PR
Except filling rule is different. Fill from enum keys.
Cause by default enum lib support getting by key, not by value.
I think it's more clear and straightforward