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

hashable Enum #1461

Merged
merged 1 commit into from
Oct 27, 2022
Merged

hashable Enum #1461

merged 1 commit into from
Oct 27, 2022

Conversation

bkad
Copy link
Contributor

@bkad bkad commented Sep 29, 2022

It would be convenient for graphene.Enum to be hashable the same way enum.Enum is so that it can be used as a key in a dict or a member of a set.

Copy link
Member

@erikwrede erikwrede left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Small comment, other than that it is good to merge! 🚀

RED = 1
GREEN = 2
BLUE = 3

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also include the instance-creation pattern for enums, to ensure completeness:
https://docs.graphene-python.org/en/latest/types/enums/#definition

Episode = graphene.Enum('Episode', [('NEWHOPE', 4), ('EMPIRE', 5), ('JEDI', 6)])

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I added a test in my amended commit.

@codecov
Copy link

codecov bot commented Oct 23, 2022

Codecov Report

Base: 95.87% // Head: 95.88% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (4f772c1) compared to base (6969023).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1461   +/-   ##
=======================================
  Coverage   95.87%   95.88%           
=======================================
  Files          50       50           
  Lines        1722     1724    +2     
=======================================
+ Hits         1651     1653    +2     
  Misses         71       71           
Impacted Files Coverage Δ
graphene/types/enum.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@erikwrede erikwrede merged commit ccdd35b into graphql-python:master Oct 27, 2022
@erikwrede
Copy link
Member

Thank you!

@bkad bkad deleted the enum-hash branch February 7, 2023 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants