File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -204,19 +204,27 @@ def is_version_at_least(version1: str, version2: str) -> bool:
204
204
205
205
Returns:
206
206
bool: True if version1 is greater than or equal to version2, False otherwise.
207
+
208
+ .. note::
209
+
210
+ Development, alpha, beta, and rc versions are considered to be equal
211
+ to the corresponding release version.
207
212
"""
208
213
# Split the version strings into parts
209
- parts1 = [int ( part ) for part in version1 .split ("." )]
210
- parts2 = [int ( part ) for part in version2 .split ("." )]
214
+ parts1 = [part . strip ( ) for part in version1 .split ("." )]
215
+ parts2 = [part . strip ( ) for part in version2 .split ("." )]
211
216
212
- # Compare each part
213
217
for part1 , part2 in zip (parts1 , parts2 ):
214
- if part1 > part2 :
218
+ if part1 .isdigit () and part2 .isdigit ():
219
+ if int (part1 ) > int (part2 ):
220
+ return True
221
+ elif int (part1 ) < int (part2 ):
222
+ return False
223
+ elif part1 > part2 :
215
224
return True
216
225
elif part1 < part2 :
217
226
return False
218
227
219
- # Check if version1 is shorter and thus less than version2
220
228
return len (parts1 ) >= len (parts2 )
221
229
222
230
You can’t perform that action at this time.
0 commit comments