Skip to content

Commit 4df3747

Browse files
Create a constant for version check and refactor existing one
1 parent 7a136fc commit 4df3747

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

pylint/checkers/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
import numbers
5151
import re
5252
import string
53-
import sys
5453
from functools import lru_cache, partial
5554
from typing import Callable, Dict, Iterable, List, Match, Optional, Set, Tuple, Union
5655

@@ -60,6 +59,8 @@
6059
from astroid import helpers, scoped_nodes
6160
from astroid.exceptions import _NonDeducibleTypeHierarchy
6261

62+
from pylint.constants import PY310_PLUS
63+
6364
BUILTINS_NAME = builtins.__name__
6465
COMP_NODE_TYPES = (
6566
astroid.ListComp,
@@ -213,7 +214,6 @@
213214
for name in methods # type: ignore
214215
}
215216
PYMETHODS = set(SPECIAL_METHODS_PARAMS)
216-
PY310_PLUS = sys.version_info[:2] >= (3, 10)
217217

218218

219219
class NoSuchArgumentError(Exception):

pylint/constants.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
from pylint.__pkginfo__ import version as pylint_version
99

10+
PY38_PLUS = sys.version_info[:2] >= (3, 8)
11+
PY310_PLUS = sys.version_info[:2] >= (3, 10)
12+
13+
1014
PY_EXTS = (".py", ".pyc", ".pyo", ".pyw", ".so", ".dll")
1115

1216
MSG_STATE_CONFIDENCE = 2

pylint/testutils/output_line.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# For details: https://github.com/PyCQA/pylint/blob/master/COPYING
33

44
import collections
5-
import sys
65

76
from pylint import interfaces
7+
from pylint.constants import PY38_PLUS
88
from pylint.testutils.constants import UPDATE_OPTION
99

1010

@@ -80,7 +80,7 @@ def from_msg(cls, msg):
8080

8181
@classmethod
8282
def get_column(cls, column):
83-
if sys.version_info.major == 3 and sys.version_info.minor < 8:
83+
if not PY38_PLUS:
8484
return ""
8585
return str(column)
8686

0 commit comments

Comments
 (0)