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 2424# MA 02110-1301, USA.
2525#
2626
27- from enum import Enum
27+ from aenum import Enum , IntEnum
2828
2929__all__ = ["IntEnum" , "StrEnum" ]
3030
3131
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)
4545
4646
47- class StrEnum (Enum ):
47+ class StrEnum (str , Enum ):
4848 """
4949 An Enum that can be converted into a string
5050 """
5151
5252 def __str__ (self ):
5353 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():
2323 assert DramatisPersonae .Message == "a secret message"
2424 assert DramatisPersonae .Alice != "An eavesdropper"
2525 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'>"
2828
2929class Numbers (enums .IntEnum ):
3030 One = 1
@@ -39,3 +39,4 @@ def test_int_enum():
3939 assert Numbers .Two != 3
4040 assert int (Numbers .Four ) == 4
4141 assert Numbers (5 ) == Numbers .Five == 5
42+ assert isinstance (Numbers (5 ), int )
You can’t perform that action at this time.
0 commit comments