Skip to content

Commit

Permalink
Fix(register): updated register_enum function support custom classes
Browse files Browse the repository at this point in the history
 Use isinstance instead of type to support instances of enum class in addition to exact same type.
  • Loading branch information
AdithyanJothir committed Apr 5, 2023
1 parent 40ee17b commit d273922
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions graphene_mongo/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def register(self, cls):

def register_enum(self, cls):
from enum import EnumMeta
assert type(cls) == EnumMeta, 'Only EnumMeta can be registered, received "{}"'.format(
cls.__name__
)
assert isinstance(
cls, EnumMeta
), f'Only EnumMeta can be registered, received "{cls.__name__}"'
if not cls.__name__.endswith('Enum'):
name = cls.__name__ + 'Enum'
else:
Expand Down

0 comments on commit d273922

Please sign in to comment.