summaryrefslogtreecommitdiff
path: root/pylint/__pkginfo__.py
diff options
context:
space:
mode:
Diffstat (limited to 'pylint/__pkginfo__.py')
-rw-r--r--pylint/__pkginfo__.py32
1 files changed, 30 insertions, 2 deletions
diff --git a/pylint/__pkginfo__.py b/pylint/__pkginfo__.py
index 8316089ec..1a1d99dd2 100644
--- a/pylint/__pkginfo__.py
+++ b/pylint/__pkginfo__.py
@@ -1,5 +1,6 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/master/LICENSE
+from typing import Tuple
from pkg_resources import DistributionNotFound, get_distribution
@@ -8,5 +9,32 @@ try:
except DistributionNotFound:
__version__ = "2.8.2+"
-# Kept for compatibility reason, see https://github.com/PyCQA/pylint/issues/4399
-numversion = tuple(__version__.split("."))
+
+def get_numversion_from_version(v: str) -> Tuple:
+ """Kept for compatibility reason
+
+ See https://github.com/PyCQA/pylint/issues/4399
+ https://github.com/PyCQA/pylint/issues/4420,
+ """
+ v = v.replace("pylint-", "")
+ version = []
+ for n in v.split(".")[0:3]:
+ try:
+ version.append(int(n))
+ except ValueError:
+ num = ""
+ for c in n:
+ if c.isdigit():
+ num += c
+ else:
+ break
+ try:
+ version.append(int(num))
+ except ValueError:
+ version.append(0)
+ while len(version) != 3:
+ version.append(0)
+ return tuple(version)
+
+
+numversion = get_numversion_from_version(__version__)