File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313
1414from __future__ import annotations
1515
16- import re
17-
1816from mailjet_rest ._version import __version__ as package_version
1917
2018
@@ -27,15 +25,16 @@ def clean_version(version_str: str) -> tuple[int, ...]:
2725 Returns:
2826 tuple: A tuple representing the version of the package.
2927 """
30- if not version_str :
28+ try :
29+ parts = version_str .split ("." )
30+ major = int (parts [0 ])
31+ minor = int (parts [1 ])
32+ # Strip any trailing prerelease tags (e.g., "1rc1" -> "1")
33+ patch = int ("" .join (c for c in parts [2 ] if c .isdigit ()))
34+ except (IndexError , ValueError ):
3135 return 0 , 0 , 0
32- # Extract just the X.Y.Z part using regex
33- match = re .match (r"^(\d+\.\d+\.\d+)" , version_str )
34- if match :
35- version_part = match .group (1 )
36- return tuple (map (int , version_part .split ("." )))
37-
38- return 0 , 0 , 0
36+ else :
37+ return (major , minor , patch )
3938
4039
4140# VERSION is a tuple of integers (1, 3, 2).
You can’t perform that action at this time.
0 commit comments