mirror of
https://github.com/graphql-python/graphene.git
synced 2025-03-05 04:15:47 +03:00
from_enum can now take a deprecation reason (#957)
This commit is contained in:
parent
abff3d75a3
commit
6a4091b3e4
8
graphene/tests/issues/test_956.py
Normal file
8
graphene/tests/issues/test_956.py
Normal file
|
@ -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"]
|
|
@ -46,7 +46,12 @@ class EnumMeta(SubclassWithMeta_Meta):
|
||||||
def __call__(cls, *args, **kwargs): # noqa: N805
|
def __call__(cls, *args, **kwargs): # noqa: N805
|
||||||
if cls is Enum:
|
if cls is Enum:
|
||||||
description = kwargs.pop("description", None)
|
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 super(EnumMeta, cls).__call__(*args, **kwargs)
|
||||||
# return cls._meta.enum(*args, **kwargs)
|
# return cls._meta.enum(*args, **kwargs)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user