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
…217)

Use isinstance instead of type to support instances of enum class in addition to exact same type.

Co-authored-by: u243606 <adithyan@strollby.com>
  • Loading branch information
AdithyanJothir and AdithyanJothir authored Apr 5, 2023
1 parent 0fd99c9 commit 807ae70
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 807ae70

Please sign in to comment.