Skip to content

Commit

Permalink
from_enum can now take a deprecation reason (#957)
Browse files Browse the repository at this point in the history
  • Loading branch information
NyanKiyoshi authored and ekampf committed May 6, 2019
1 parent abff3d7 commit 6a4091b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions graphene/tests/issues/test_956.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import graphene


def test_issue():
options = {"description": "This my enum", "deprecation_reason": "For the funs"}
new_enum = graphene.Enum("MyEnum", [("some", "data")], **options)
assert new_enum._meta.description == options["description"]
assert new_enum._meta.deprecation_reason == options["deprecation_reason"]
7 changes: 6 additions & 1 deletion graphene/types/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ def __prepare__(name, bases, **kwargs): # noqa: N805
def __call__(cls, *args, **kwargs): # noqa: N805
if cls is Enum:
description = kwargs.pop("description", None)
return cls.from_enum(PyEnum(*args, **kwargs), description=description)
deprecation_reason = kwargs.pop("deprecation_reason", None)
return cls.from_enum(
PyEnum(*args, **kwargs),
description=description,
deprecation_reason=deprecation_reason,
)
return super(EnumMeta, cls).__call__(*args, **kwargs)
# return cls._meta.enum(*args, **kwargs)

Expand Down

0 comments on commit 6a4091b

Please sign in to comment.