absurdfarce commented on code in PR #1273:
URL: 
https://github.com/apache/cassandra-python-driver/pull/1273#discussion_r2892569064


##########
cassandra/util.py:
##########
@@ -1692,54 +1692,43 @@ def __repr__(self):
             self.lower_bound, self.upper_bound, self.value
         )
 
+VERSION_REGEX = 
re.compile("(\\d+)\\.(\\d+)(\\.\\d+)?(\\.\\d+)?([~\\-]\\w[.\\w]*(?:-\\w[.\\w]*)*)?(\\+[.\\w]+)?")
 
 @total_ordering
 class Version(object):
-    """
-    Internal minimalist class to compare versions.
-    A valid version is: <int>.<int>.<int>.<int or str>.
-
-    TODO: when python2 support is removed, use packaging.version.
-    """
-
-    _version = None
-    major = None
-    minor = 0
-    patch = 0
-    build = 0
-    prerelease = 0
 
     def __init__(self, version):
         self._version = version
-        if '-' in version:
-            version_without_prerelease, self.prerelease = version.split('-', 1)
-        else:
-            version_without_prerelease = version
-        parts = list(reversed(version_without_prerelease.split('.')))
-        if len(parts) > 4:
-            prerelease_string = "-{}".format(self.prerelease) if 
self.prerelease else ""
-            log.warning("Unrecognized version: {}. Only 4 components plus 
prerelease are supported. "
-                        "Assuming version as {}{}".format(version, 
'.'.join(parts[:-5:-1]), prerelease_string))
+
+        match = VERSION_REGEX.match(version)
+        if not match:
+            raise ValueError("Version string did not match expected format")

Review Comment:
   Also a fair point.  Anchors make more sense given the overall context here 
so I'll add those just to be explicit.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to