Comparison issue for Enum
See original GitHub issueSince Enum
use is
operator to check equality, it will fail if the other value is not the same object as Enum.value
.
Code:
from graphene import Enum
big_value = 99999999999999
big_string = 'hello' * 100
class MyEnum(Enum):
TypeA = 99999999999999
TypeB = 'hello' * 100
assert MyEnum.TypeA == big_value
assert MyEnum.TypeB == big_string
Expect result: Everything works fine.
Result:
assertion failed for both.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Comparing Java enum members: == or equals()?
Because there is only one instance of each enum constant, it is permissible to use the == operator in place of the equals...
Read more >Comparing enum members in Java - GeeksforGeeks
When we use == operator for comparison, then we are not getting any Exception whereas when we use .equals() method then we are...
Read more >Comparing enum members in Java - Tutorialspoint
Using Enum.compareTo() method. compareTo() method compares this enum with the specified object for order. · Using Enum.equals() method. · Using == ...
Read more >Javarevisited: How to Compare Two Enum in Java? Equals vs ...
Though you can compare two Enum using equals() and == method for equality check, there is subtle difference between them.
Read more >Comparing Enum values in Java - Medium
Comparing Enum values in Java ... The common sense rule in Java is that when comparing things, objects always get compared with objectA.equals(objectB)...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Fity you need to do:
Ah I didn’t know about that. Thanks!