summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Mueller <30130371+cdce8p@users.noreply.github.com>2021-11-25 16:35:46 +0100
committerGitHub <noreply@github.com>2021-11-25 16:35:46 +0100
commita9c1017929e586173dfb907315793727e7eb0389 (patch)
tree4f04f6a0a4caf2b03816a12d5088582ca521351a
parent1f7f2e96c39ee89ee9fb18ab23f3dfbb9325c870 (diff)
downloadpylint-git-a9c1017929e586173dfb907315793727e7eb0389.tar.gz
Require Python 3.6.2 (#5068)
* Bump python_requires to >= 3.6.2 * Import typing names directly * Use typing.NamedTuple for MessageTest * Add default value to MessageStyle * Revert "Add an exception at install for python < 3.6.2 (#5171)" This reverts commit 37e330cadd12800b484ef89cd599dcb06f1ba539. Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
-rw-r--r--ChangeLog4
-rw-r--r--README.rst2
-rw-r--r--doc/faq.rst2
-rw-r--r--doc/whatsnew/2.13.rst4
-rw-r--r--pylint/checkers/strings.py8
-rw-r--r--pylint/message/message_id_store.py8
-rw-r--r--pylint/reporters/text.py8
-rw-r--r--pylint/testutils/lint_module_test.py30
-rw-r--r--pylintrc2
-rw-r--r--requirements_test_pre_commit.txt2
-rw-r--r--setup.py17
-rw-r--r--tests/lint/test_pylinter.py8
12 files changed, 34 insertions, 61 deletions
diff --git a/ChangeLog b/ChangeLog
index f58ab1c8d..db75ce76e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -22,6 +22,10 @@ Release date: TBA
..
Put bug fixes that should not wait for a new minor version here
+* Require Python ``3.6.2`` to run pylint.
+
+ Closes #5065
+
..
Insert your changelog randomly, it will reduce merge conflicts
(Ie. not necessarily at the end)
diff --git a/README.rst b/README.rst
index 388a974cc..32871e01c 100644
--- a/README.rst
+++ b/README.rst
@@ -75,7 +75,7 @@ Pylint can be simply installed by running::
pip install pylint
-If you are using Python 3.6+, upgrade to get full support for your version::
+If you are using Python 3.6.2+, upgrade to get full support for your version::
pip install pylint --upgrade
diff --git a/doc/faq.rst b/doc/faq.rst
index d0a02cf3a..6a401bf25 100644
--- a/doc/faq.rst
+++ b/doc/faq.rst
@@ -48,7 +48,7 @@ supported.
2.4 What versions of Python is Pylint supporting?
--------------------------------------------------
-The supported running environment since Pylint 2.7.X is Python 3.6+.
+The supported running environment since Pylint 2.12.1 is Python 3.6.2+.
3. Running Pylint
diff --git a/doc/whatsnew/2.13.rst b/doc/whatsnew/2.13.rst
index fff0e9318..378b4103b 100644
--- a/doc/whatsnew/2.13.rst
+++ b/doc/whatsnew/2.13.rst
@@ -19,3 +19,7 @@ Extensions
Other Changes
=============
+
+* Require Python ``3.6.2`` to run pylint.
+
+ Closes #5065
diff --git a/pylint/checkers/strings.py b/pylint/checkers/strings.py
index eb43411de..fb145eaf8 100644
--- a/pylint/checkers/strings.py
+++ b/pylint/checkers/strings.py
@@ -41,7 +41,7 @@ import collections
import numbers
import re
import tokenize
-from typing import TYPE_CHECKING, Iterable
+from typing import Counter, Iterable
import astroid
from astroid import nodes
@@ -50,9 +50,6 @@ from pylint.checkers import BaseChecker, BaseTokenChecker, utils
from pylint.checkers.utils import check_messages
from pylint.interfaces import IAstroidChecker, IRawChecker, ITokenChecker
-if TYPE_CHECKING:
- from typing import Counter # typing.Counter added in Python 3.6.1
-
_AST_NODE_STR_TYPES = ("__builtin__.unicode", "__builtin__.str", "builtins.str")
# Prefixes for both strings and bytes literals per
# https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals
@@ -774,8 +771,7 @@ class StringConstantChecker(BaseTokenChecker):
Args:
tokens: The tokens to be checked against for consistent usage.
"""
- # typing.Counter added in Python 3.6.1 so this type hint must be a comment
- string_delimiters = collections.Counter() # type: Counter[str]
+ string_delimiters: Counter[str] = collections.Counter()
# First, figure out which quote character predominates in the module
for tok_type, token, _, _, _ in tokens:
diff --git a/pylint/message/message_id_store.py b/pylint/message/message_id_store.py
index 87e185ac7..1fbe68471 100644
--- a/pylint/message/message_id_store.py
+++ b/pylint/message/message_id_store.py
@@ -1,15 +1,9 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-import sys
-from typing import Dict, List, Optional, Tuple
+from typing import Dict, List, NoReturn, Optional, Tuple
from pylint.exceptions import InvalidMessageError, UnknownMessageError
-if sys.version_info >= (3, 6, 2):
- from typing import NoReturn
-else:
- from typing_extensions import NoReturn
-
class MessageIdStore:
diff --git a/pylint/reporters/text.py b/pylint/reporters/text.py
index 196bee9d8..7ab78e1b8 100644
--- a/pylint/reporters/text.py
+++ b/pylint/reporters/text.py
@@ -59,7 +59,7 @@ class MessageStyle(NamedTuple):
"""The color name (see `ANSI_COLORS` for available values)
or the color number when 256 colors are available
"""
- style: Tuple[str, ...]
+ style: Tuple[str, ...] = ()
"""Tuple of style strings (see `ANSI_COLORS` for available values).
"""
@@ -264,10 +264,10 @@ class ColorizedTextReporter(TextReporter):
name = "colorized"
COLOR_MAPPING: ColorMappingDict = {
- "I": MessageStyle("green", ()),
+ "I": MessageStyle("green"),
"C": MessageStyle(None, ("bold",)),
"R": MessageStyle("magenta", ("bold", "italic")),
- "W": MessageStyle("magenta", ()),
+ "W": MessageStyle("magenta"),
"E": MessageStyle("red", ("bold",)),
"F": MessageStyle("red", ("bold", "underline")),
"S": MessageStyle("yellow", ("inverse",)), # S stands for module Separator
@@ -326,7 +326,7 @@ class ColorizedTextReporter(TextReporter):
def _get_decoration(self, msg_id: str) -> MessageStyle:
"""Returns the message style as defined in self.color_mapping"""
- return self.color_mapping.get(msg_id[0]) or MessageStyle(None, ())
+ return self.color_mapping.get(msg_id[0]) or MessageStyle(None)
def handle_message(self, msg: Message) -> None:
"""manage message of different types, and colorize output
diff --git a/pylint/testutils/lint_module_test.py b/pylint/testutils/lint_module_test.py
index 859f1c6c9..8edc63876 100644
--- a/pylint/testutils/lint_module_test.py
+++ b/pylint/testutils/lint_module_test.py
@@ -7,7 +7,8 @@ import platform
import sys
from collections import Counter
from io import StringIO
-from typing import TYPE_CHECKING, Dict, List, Optional, TextIO, Tuple
+from typing import Counter as CounterType
+from typing import Dict, List, Optional, TextIO, Tuple
import pytest
from _pytest.config import Config
@@ -25,10 +26,7 @@ from pylint.testutils.output_line import OutputLine
from pylint.testutils.reporter_for_tests import FunctionalTestReporter
from pylint.utils import utils
-if TYPE_CHECKING:
- from typing import Counter as CounterType # typing.Counter added in Python 3.6.1
-
- MessageCounter = CounterType[Tuple[int, str]]
+MessageCounter = CounterType[Tuple[int, str]]
class LintModuleTest:
@@ -99,7 +97,7 @@ class LintModuleTest:
return f"{self._test_file.base} ({self.__class__.__module__}.{self.__class__.__name__})"
@staticmethod
- def get_expected_messages(stream: TextIO) -> "MessageCounter":
+ def get_expected_messages(stream: TextIO) -> MessageCounter:
"""Parses a file and get expected messages.
:param stream: File-like input stream.
@@ -107,7 +105,7 @@ class LintModuleTest:
:returns: A dict mapping line,msg-symbol tuples to the count on this line.
:rtype: dict
"""
- messages: "MessageCounter" = Counter()
+ messages: MessageCounter = Counter()
for i, line in enumerate(stream):
match = _EXPECTED_RE.search(line)
if match is None:
@@ -133,9 +131,9 @@ class LintModuleTest:
@staticmethod
def multiset_difference(
- expected_entries: "MessageCounter",
- actual_entries: "MessageCounter",
- ) -> Tuple["MessageCounter", Dict[Tuple[int, str], int]]:
+ expected_entries: MessageCounter,
+ actual_entries: MessageCounter,
+ ) -> Tuple[MessageCounter, Dict[Tuple[int, str], int]]:
"""Takes two multisets and compares them.
A multiset is a dict with the cardinality of the key as the value."""
@@ -162,7 +160,7 @@ class LintModuleTest:
return open(self._test_file.source, encoding="latin1")
return open(self._test_file.source, encoding="utf8")
- def _get_expected(self) -> Tuple["MessageCounter", List[OutputLine]]:
+ def _get_expected(self) -> Tuple[MessageCounter, List[OutputLine]]:
with self._open_source_file() as f:
expected_msgs = self.get_expected_messages(f)
if not expected_msgs:
@@ -174,10 +172,10 @@ class LintModuleTest:
]
return expected_msgs, expected_output_lines
- def _get_actual(self) -> Tuple["MessageCounter", List[OutputLine]]:
+ def _get_actual(self) -> Tuple[MessageCounter, List[OutputLine]]:
messages: List[Message] = self._linter.reporter.messages
messages.sort(key=lambda m: (m.line, m.symbol, m.msg))
- received_msgs: "MessageCounter" = Counter()
+ received_msgs: MessageCounter = Counter()
received_output_lines = []
for msg in messages:
assert (
@@ -204,8 +202,8 @@ class LintModuleTest:
def error_msg_for_unequal_messages(
self,
- actual_messages: "MessageCounter",
- expected_messages: "MessageCounter",
+ actual_messages: MessageCounter,
+ expected_messages: MessageCounter,
actual_output: List[OutputLine],
) -> str:
msg = [f'Wrong results for file "{self._test_file.base}":']
@@ -250,7 +248,7 @@ class LintModuleTest:
def _check_output_text(
self,
- _: "MessageCounter",
+ _: MessageCounter,
expected_output: List[OutputLine],
actual_output: List[OutputLine],
) -> None:
diff --git a/pylintrc b/pylintrc
index 3005cc676..a38a35aed 100644
--- a/pylintrc
+++ b/pylintrc
@@ -44,7 +44,7 @@ unsafe-load-any-extension=no
extension-pkg-allow-list=
# Minimum supported python version
-py-version = 3.6
+py-version = 3.6.2
[MESSAGES CONTROL]
diff --git a/requirements_test_pre_commit.txt b/requirements_test_pre_commit.txt
index cf351dde3..1ce76e355 100644
--- a/requirements_test_pre_commit.txt
+++ b/requirements_test_pre_commit.txt
@@ -1,6 +1,6 @@
# Everything in this file should reflect the pre-commit configuration
# in .pre-commit-config.yaml
-black==21.11b1;python_full_version>="3.6.2"
+black==21.11b1
flake8==4.0.1
flake8-typing-imports==1.10.1
isort==5.10.1
diff --git a/setup.py b/setup.py
index a6ee6b4aa..606849326 100644
--- a/setup.py
+++ b/setup.py
@@ -1,20 +1,3 @@
-import sys
-
from setuptools import setup
-
-class PylintIncompatiblePythonError(Exception):
- def __init__(self) -> None:
- super().__init__(
- "The last version compatible with Python <= 3.6.2 is pylint '2.9.3'. "
- f"You're using {'.'.join([str(v) for v in sys.version_info[:3]])}. "
- "Please install pylint 2.9.3 explicitly or upgrade your python interpreter "
- "to at least 3.6.2. Remember that Python 3.6 end life is December 2021. "
- "See https://github.com/PyCQA/pylint/issues/5065 for more detail."
- )
-
-
-if sys.version_info < (3, 6, 2):
- raise PylintIncompatiblePythonError()
-
setup()
diff --git a/tests/lint/test_pylinter.py b/tests/lint/test_pylinter.py
index 74ddde2ed..9d6695a25 100644
--- a/tests/lint/test_pylinter.py
+++ b/tests/lint/test_pylinter.py
@@ -1,5 +1,4 @@
-import sys
-from typing import Any
+from typing import Any, NoReturn
from unittest.mock import patch
from astroid import AstroidBuildingError
@@ -9,11 +8,6 @@ from pytest import CaptureFixture
from pylint.lint.pylinter import PyLinter
from pylint.utils import FileState
-if sys.version_info >= (3, 6, 2):
- from typing import NoReturn
-else:
- from typing_extensions import NoReturn
-
def raise_exception(*args: Any, **kwargs: Any) -> NoReturn:
raise AstroidBuildingError(modname="spam")