@@ -143,7 +143,7 @@ def is_eol(self) -> bool:
143143 @property
144144 def is_rc (self ) -> bool :
145145 """Check if this version is a release candidate."""
146- return self .suffix .lower ().startswith ("rc" )
146+ return self .suffix .lower ().startswith ("- rc" )
147147
148148 @property
149149 def is_ga (self ) -> bool :
@@ -153,24 +153,33 @@ def is_ga(self) -> bool:
153153 @property
154154 def is_internal (self ) -> bool :
155155 """Check if this version is an internal release."""
156- return self .suffix .lower (). startswith ( "int" )
156+ return bool ( re . search ( r"-int\d*$" , self .suffix .lower ()) )
157157
158158 @property
159159 def mainline_version (self ) -> str :
160160 """Get the mainline version string (major.minor)."""
161161 return f"{ self .major } .{ self .minor } "
162162
163163 @property
164- def sort_key (self ) -> str :
165- suffix_weight = 0
166- if self .suffix .startswith ("rc" ):
167- suffix_weight = 100
168- elif self .suffix .startswith ("m" ):
169- suffix_weight = 50
164+ def suffix_weight (self ) -> str :
165+ # warning: using lexicographic order, letters doesn't have any meaning except for ordering
166+ suffix_weight = ""
167+ if self .is_ga :
168+ suffix_weight = "QQ"
169+ if self .is_rc :
170+ suffix_weight = "LL"
171+ elif self .suffix .startswith ("-m" ):
172+ suffix_weight = "II"
173+
174+ # internal versions are always lower than their GA/rc/m counterparts
175+ if self .is_internal :
176+ suffix_weight = suffix_weight [0 ] + "E"
177+
178+ return suffix_weight
170179
171- return (
172- f" { self . major } . { self . minor } . { self . patch or 0 } . { suffix_weight } . { self . suffix } "
173- )
180+ @ property
181+ def sort_key ( self ) -> str :
182+ return f" { self . major } . { self . minor } . { self . patch or 0 } . { self . suffix_weight } { self . suffix } "
174183
175184 def __str__ (self ) -> str :
176185 """String representation of the version."""
@@ -184,21 +193,7 @@ def __lt__(self, other: "RedisVersion") -> bool:
184193 if not isinstance (other , RedisVersion ):
185194 return NotImplemented
186195
187- # Compare major.minor.patch first
188- self_tuple = (self .major , self .minor , self .patch or 0 )
189- other_tuple = (other .major , other .minor , other .patch or 0 )
190-
191- if self_tuple != other_tuple :
192- return self_tuple < other_tuple
193-
194- # If numeric parts are equal, compare suffixes
195- # Empty suffix (GA) comes after suffixes (milestones)
196- if not self .suffix and other .suffix :
197- return False
198- if self .suffix and not other .suffix :
199- return True
200-
201- return self .suffix < other .suffix
196+ return self .sort_key < other .sort_key
202197
203198 def __le__ (self , other : "RedisVersion" ) -> bool :
204199 """Less than or equal comparison."""
0 commit comments