Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default enum description to "An enumeration." #1502

Merged
merged 5 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion graphene/types/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def from_enum(
cls, enum, name=None, description=None, deprecation_reason=None
): # noqa: N805
name = name or enum.__name__
description = description or enum.__doc__
description = description or enum.__doc__ or "An enumeration."
meta_dict = {
"enum": enum,
"description": description,
Expand Down
13 changes: 13 additions & 0 deletions graphene/types/tests/test_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,19 @@ def test_enum_from_builtin_enum():
assert RGB.GREEN
assert RGB.BLUE

def test_enum_custom_description_in_constructor():
description = "An enumeration, but with a custom description"
RGB = Enum(
"RGB",
"RED,GREEN,BLUE",
description=description,
)
assert RGB._meta.description == description


def test_enum_from_python3_enum_uses_default_builtin_doc():
RGB = Enum("RGB", "RED,GREEN,BLUE")
assert RGB._meta.description == "An enumeration."

def test_enum_from_builtin_enum_accepts_lambda_description():
def custom_description(value):
Expand Down