@@ -105,14 +105,18 @@ def from_value(value: str):
105
105
elif value .startswith ("regexp:" ):
106
106
return RegexPolicy (re .compile (value [7 :], re .IGNORECASE ))
107
107
else :
108
- return SemverPolicyType .from_value (value )
108
+ return SemverPolicy .from_value (value )
109
+
110
+ @property
111
+ def value (self ):
112
+ return self .__str__ ()
109
113
110
114
@abc .abstractmethod
111
115
def __str__ (self ):
112
116
raise NotImplementedError ()
113
117
114
118
115
- class SemverPolicyType (Policy ):
119
+ class SemverPolicyType (enum . Enum ):
116
120
"""
117
121
Enum for semver policy types
118
122
"""
@@ -123,16 +127,14 @@ class SemverPolicyType(Policy):
123
127
Patch = "patch"
124
128
Force = "force"
125
129
126
- @staticmethod
127
- def values () -> ["SemverPolicyType" ]:
128
- return [
129
- SemverPolicyType .NNone ,
130
- SemverPolicyType .All ,
131
- SemverPolicyType .Major ,
132
- SemverPolicyType .Minor ,
133
- SemverPolicyType .Patch ,
134
- SemverPolicyType .Force
135
- ]
130
+
131
+ class SemverPolicy (Policy ):
132
+ """
133
+ Enum for semver policy types
134
+ """
135
+
136
+ def __init__ (self , policy_type : SemverPolicyType ):
137
+ self ._policy_type = policy_type
136
138
137
139
@staticmethod
138
140
def from_value (value : str ):
@@ -141,13 +143,13 @@ def from_value(value: str):
141
143
:param value: the value to convert
142
144
:return: the enum
143
145
"""
144
- for policy in SemverPolicyType . values () :
146
+ for policy in SemverPolicyType :
145
147
if policy .value .lower () == value .lower ():
146
148
return policy
147
- return SemverPolicyType .NNone
149
+ return SemverPolicy ( SemverPolicyType .NNone )
148
150
149
151
def __str__ (self ):
150
- return self .value
152
+ return self ._policy_type . __str__ ()
151
153
152
154
153
155
class GlobPolicy (Policy ):
0 commit comments