Skip to content

Commit 6a4091b

Browse files
NyanKiyoshiekampf
authored andcommitted
from_enum can now take a deprecation reason (#957)
1 parent abff3d7 commit 6a4091b

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

graphene/tests/issues/test_956.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import graphene
2+
3+
4+
def test_issue():
5+
options = {"description": "This my enum", "deprecation_reason": "For the funs"}
6+
new_enum = graphene.Enum("MyEnum", [("some", "data")], **options)
7+
assert new_enum._meta.description == options["description"]
8+
assert new_enum._meta.deprecation_reason == options["deprecation_reason"]

graphene/types/enum.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@ def __prepare__(name, bases, **kwargs): # noqa: N805
4646
def __call__(cls, *args, **kwargs): # noqa: N805
4747
if cls is Enum:
4848
description = kwargs.pop("description", None)
49-
return cls.from_enum(PyEnum(*args, **kwargs), description=description)
49+
deprecation_reason = kwargs.pop("deprecation_reason", None)
50+
return cls.from_enum(
51+
PyEnum(*args, **kwargs),
52+
description=description,
53+
deprecation_reason=deprecation_reason,
54+
)
5055
return super(EnumMeta, cls).__call__(*args, **kwargs)
5156
# return cls._meta.enum(*args, **kwargs)
5257

0 commit comments

Comments
 (0)