File tree Expand file tree Collapse file tree 3 files changed +29
-27
lines changed Expand file tree Collapse file tree 3 files changed +29
-27
lines changed Original file line number Diff line number Diff line change 24
24
# MA 02110-1301, USA.
25
25
#
26
26
27
- from enum import Enum
27
+ from aenum import Enum , IntEnum
28
28
29
29
__all__ = ["IntEnum" , "StrEnum" ]
30
30
31
31
32
- class IntEnum (Enum ):
33
- """
34
- An Enum that can be converted into an integer
35
- """
36
-
37
- def __int__ (self ):
38
- return self .value
39
-
40
- def __eq__ (self , other ):
41
- if int (self ) == other :
42
- return True
43
- else :
44
- return super ().__eq__ (other )
32
+ # class IntEnum(Enum):
33
+ # """
34
+ # An Enum that can be converted into an integer
35
+ # """
36
+ #
37
+ # def __int__(self):
38
+ # return self.value
39
+ #
40
+ # def __eq__(self, other):
41
+ # if int(self) == other:
42
+ # return True
43
+ # else:
44
+ # return super().__eq__(other)
45
45
46
46
47
- class StrEnum (Enum ):
47
+ class StrEnum (str , Enum ):
48
48
"""
49
49
An Enum that can be converted into a string
50
50
"""
51
51
52
52
def __str__ (self ):
53
53
return self .value
54
-
55
- def __repr__ (self ):
56
- return self .value
57
-
58
- def __eq__ (self , other ):
59
- if str (self ) == other :
60
- return True
61
- else :
62
- return super ().__eq__ (other )
54
+ #
55
+ # def __repr__(self):
56
+ # return self.value
57
+
58
+ # def __eq__(self, other):
59
+ # if str(self) == other:
60
+ # return True
61
+ # else:
62
+ # return super().__eq__(other)
Original file line number Diff line number Diff line change 1
- pydash >= 4.7.4
1
+ pydash >= 4.7.4
2
+ aenum >= 2.2.3
Original file line number Diff line number Diff line change @@ -23,8 +23,8 @@ def test_str_enum():
23
23
assert DramatisPersonae .Message == "a secret message"
24
24
assert DramatisPersonae .Alice != "An eavesdropper"
25
25
assert str (DramatisPersonae .Craig ) == "A password cracker"
26
- assert DramatisPersonae ("The sender" ) == DramatisPersonae .Bob == repr ( DramatisPersonae . Bob ) == "The sender"
27
-
26
+ assert DramatisPersonae ("The sender" ) == DramatisPersonae .Bob == "The sender"
27
+ assert repr ( DramatisPersonae . Bob ) == "<DramatisPersonae.Bob: 'The sender'>"
28
28
29
29
class Numbers (enums .IntEnum ):
30
30
One = 1
@@ -39,3 +39,4 @@ def test_int_enum():
39
39
assert Numbers .Two != 3
40
40
assert int (Numbers .Four ) == 4
41
41
assert Numbers (5 ) == Numbers .Five == 5
42
+ assert isinstance (Numbers (5 ), int )
You can’t perform that action at this time.
0 commit comments