Skip to content

Improved enums comparison and getters #446

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

Merged
merged 1 commit into from
Apr 13, 2017
Merged

Conversation

syrusakbary
Copy link
Member

This PR adds the ability to compare graphene.Enum members with their values:

class RGB(Enum):
    RED = 1
    GREEN = 2
    BLUE = 3

assert RGB.RED == 1
assert RGB.GREEN == 2
assert RGB.BLUE == 3

Also, adds a similar syntax to the native Python Enum getters:

class RGB(Enum):
    RED = 1
    GREEN = 2
    BLUE = 3

assert RGB.get(1) == RGB.RED
assert RGB['RED'] == RGB.RED

@dewiniaid

@coveralls
Copy link

coveralls commented Apr 8, 2017

Coverage Status

Coverage increased (+0.03%) to 96.329% when pulling afed25a on features/improved-enums into aaf9e92 on master.

@syrusakbary
Copy link
Member Author

@dewiniaid feel free to review this PR and let me know if you have any suggestion!

@syrusakbary syrusakbary merged commit b8323ed into master Apr 13, 2017
@syrusakbary syrusakbary deleted the features/improved-enums branch November 15, 2017 06:56
@avivey avivey mentioned this pull request Dec 17, 2018
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