summaryrefslogtreecommitdiff
path: root/pylint/checkers
diff options
context:
space:
mode:
authorMarc Mueller <30130371+cdce8p@users.noreply.github.com>2023-04-24 22:36:24 +0200
committerGitHub <noreply@github.com>2023-04-24 22:36:24 +0200
commit3ff19e4ca34fde316881d916f9df22d3104d6464 (patch)
tree22a51fd2384d9b1fe1f3fd005752155031dfd036 /pylint/checkers
parentb36a6169069ad9694b63596eeaf2c95ce1c517f9 (diff)
downloadpylint-git-3ff19e4ca34fde316881d916f9df22d3104d6464.tar.gz
Drop support for Python 3.7 (#8609)
* Drop support for Python 3.7 * Update py-version + classifier * Update functional tests
Diffstat (limited to 'pylint/checkers')
-rw-r--r--pylint/checkers/__init__.py8
-rw-r--r--pylint/checkers/base/basic_checker.py8
-rw-r--r--pylint/checkers/base/docstring_checker.py7
-rw-r--r--pylint/checkers/classes/class_checker.py7
-rw-r--r--pylint/checkers/format.py7
-rw-r--r--pylint/checkers/imports.py6
-rw-r--r--pylint/checkers/logging.py8
-rw-r--r--pylint/checkers/raw_metrics.py8
-rw-r--r--pylint/checkers/refactoring/refactoring_checker.py7
-rw-r--r--pylint/checkers/spelling.py8
-rw-r--r--pylint/checkers/strings.py8
-rw-r--r--pylint/checkers/typecheck.py11
-rw-r--r--pylint/checkers/utils.py2
-rw-r--r--pylint/checkers/variables.py7
14 files changed, 15 insertions, 87 deletions
diff --git a/pylint/checkers/__init__.py b/pylint/checkers/__init__.py
index 8af4bae67..0f9985918 100644
--- a/pylint/checkers/__init__.py
+++ b/pylint/checkers/__init__.py
@@ -42,8 +42,7 @@ messages nor reports. XXX not true, emit a 07 report !
from __future__ import annotations
-import sys
-from typing import TYPE_CHECKING
+from typing import TYPE_CHECKING, Literal
from pylint.checkers.base_checker import (
BaseChecker,
@@ -53,11 +52,6 @@ from pylint.checkers.base_checker import (
from pylint.checkers.deprecated import DeprecatedMixin
from pylint.utils import LinterStats, diff_string, register_plugins
-if sys.version_info >= (3, 8):
- from typing import Literal
-else:
- from typing_extensions import Literal
-
if TYPE_CHECKING:
from pylint.lint import PyLinter
diff --git a/pylint/checkers/base/basic_checker.py b/pylint/checkers/base/basic_checker.py
index dd46d8553..627f3c603 100644
--- a/pylint/checkers/base/basic_checker.py
+++ b/pylint/checkers/base/basic_checker.py
@@ -8,9 +8,8 @@ from __future__ import annotations
import collections
import itertools
-import sys
from collections.abc import Iterator
-from typing import TYPE_CHECKING, cast
+from typing import TYPE_CHECKING, Literal, cast
import astroid
from astroid import nodes, objects, util
@@ -24,11 +23,6 @@ from pylint.utils import LinterStats
if TYPE_CHECKING:
from pylint.lint.pylinter import PyLinter
-if sys.version_info >= (3, 8):
- from typing import Literal
-else:
- from typing_extensions import Literal
-
class _BasicChecker(BaseChecker):
"""Permits separating multiple checks with the same checker name into
diff --git a/pylint/checkers/base/docstring_checker.py b/pylint/checkers/base/docstring_checker.py
index 5a681eeb3..91b3e7d4a 100644
--- a/pylint/checkers/base/docstring_checker.py
+++ b/pylint/checkers/base/docstring_checker.py
@@ -7,7 +7,7 @@
from __future__ import annotations
import re
-import sys
+from typing import Literal
import astroid
from astroid import nodes
@@ -21,11 +21,6 @@ from pylint.checkers.utils import (
is_property_setter,
)
-if sys.version_info >= (3, 8):
- from typing import Literal
-else:
- from typing_extensions import Literal
-
# do not require a doc string on private/system methods
NO_REQUIRED_DOC_RGX = re.compile("^_")
diff --git a/pylint/checkers/classes/class_checker.py b/pylint/checkers/classes/class_checker.py
index 9b0bd50b1..77a795bcb 100644
--- a/pylint/checkers/classes/class_checker.py
+++ b/pylint/checkers/classes/class_checker.py
@@ -7,9 +7,9 @@
from __future__ import annotations
import collections
-import sys
from collections import defaultdict
from collections.abc import Callable, Sequence
+from functools import cached_property
from itertools import chain, zip_longest
from re import Pattern
from typing import TYPE_CHECKING, Any, Union
@@ -47,11 +47,6 @@ if TYPE_CHECKING:
from pylint.lint.pylinter import PyLinter
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from astroid.decorators import cachedproperty as cached_property
-
_AccessNodes = Union[nodes.Attribute, nodes.AssignAttr]
INVALID_BASE_CLASSES = {"bool", "range", "slice", "memoryview"}
diff --git a/pylint/checkers/format.py b/pylint/checkers/format.py
index 62466a4fd..3e3cd3227 100644
--- a/pylint/checkers/format.py
+++ b/pylint/checkers/format.py
@@ -13,11 +13,10 @@ Some parts of the process_token method is based from The Tab Nanny std module.
from __future__ import annotations
-import sys
import tokenize
from functools import reduce
from re import Match
-from typing import TYPE_CHECKING
+from typing import TYPE_CHECKING, Literal
from astroid import nodes
@@ -31,10 +30,6 @@ from pylint.utils.pragma_parser import OPTION_PO, PragmaParserError, parse_pragm
if TYPE_CHECKING:
from pylint.lint import PyLinter
-if sys.version_info >= (3, 8):
- from typing import Literal
-else:
- from typing_extensions import Literal
_KEYWORD_TOKENS = {
"assert",
diff --git a/pylint/checkers/imports.py b/pylint/checkers/imports.py
index 6cc5d2164..42649f3d9 100644
--- a/pylint/checkers/imports.py
+++ b/pylint/checkers/imports.py
@@ -12,6 +12,7 @@ import os
import sys
from collections import defaultdict
from collections.abc import ItemsView, Sequence
+from functools import cached_property
from typing import TYPE_CHECKING, Any, Dict, List, Union
import astroid
@@ -38,11 +39,6 @@ from pylint.utils.linterstats import LinterStats
if TYPE_CHECKING:
from pylint.lint import PyLinter
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from astroid.decorators import cachedproperty as cached_property
-
# The dictionary with Any should actually be a _ImportTree again
# but mypy doesn't support recursive types yet
diff --git a/pylint/checkers/logging.py b/pylint/checkers/logging.py
index e5fb1ae09..461047bdf 100644
--- a/pylint/checkers/logging.py
+++ b/pylint/checkers/logging.py
@@ -7,8 +7,7 @@
from __future__ import annotations
import string
-import sys
-from typing import TYPE_CHECKING
+from typing import TYPE_CHECKING, Literal
import astroid
from astroid import bases, nodes
@@ -19,11 +18,6 @@ from pylint.checkers import utils
from pylint.checkers.utils import infer_all
from pylint.typing import MessageDefinitionTuple
-if sys.version_info >= (3, 8):
- from typing import Literal
-else:
- from typing_extensions import Literal
-
if TYPE_CHECKING:
from pylint.lint import PyLinter
diff --git a/pylint/checkers/raw_metrics.py b/pylint/checkers/raw_metrics.py
index 301e9d2e2..ef4535345 100644
--- a/pylint/checkers/raw_metrics.py
+++ b/pylint/checkers/raw_metrics.py
@@ -4,19 +4,13 @@
from __future__ import annotations
-import sys
import tokenize
-from typing import TYPE_CHECKING, Any, cast
+from typing import TYPE_CHECKING, Any, Literal, cast
from pylint.checkers import BaseTokenChecker
from pylint.reporters.ureports.nodes import Paragraph, Section, Table, Text
from pylint.utils import LinterStats, diff_string
-if sys.version_info >= (3, 8):
- from typing import Literal
-else:
- from typing_extensions import Literal
-
if TYPE_CHECKING:
from pylint.lint import PyLinter
diff --git a/pylint/checkers/refactoring/refactoring_checker.py b/pylint/checkers/refactoring/refactoring_checker.py
index 890b0e64d..5d0a2dd7a 100644
--- a/pylint/checkers/refactoring/refactoring_checker.py
+++ b/pylint/checkers/refactoring/refactoring_checker.py
@@ -7,10 +7,9 @@ from __future__ import annotations
import collections
import copy
import itertools
-import sys
import tokenize
from collections.abc import Iterator
-from functools import reduce
+from functools import cached_property, reduce
from re import Pattern
from typing import TYPE_CHECKING, Any, NamedTuple, Union, cast
@@ -27,10 +26,6 @@ from pylint.interfaces import HIGH, INFERENCE, Confidence
if TYPE_CHECKING:
from pylint.lint import PyLinter
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from astroid.decorators import cachedproperty as cached_property
NodesWithNestedBlocks = Union[
nodes.TryExcept, nodes.TryFinally, nodes.While, nodes.For, nodes.If
diff --git a/pylint/checkers/spelling.py b/pylint/checkers/spelling.py
index 8ba4df4d5..91161c60d 100644
--- a/pylint/checkers/spelling.py
+++ b/pylint/checkers/spelling.py
@@ -7,21 +7,15 @@
from __future__ import annotations
import re
-import sys
import tokenize
from re import Pattern
-from typing import TYPE_CHECKING, Any
+from typing import TYPE_CHECKING, Any, Literal
from astroid import nodes
from pylint.checkers import BaseTokenChecker
from pylint.checkers.utils import only_required_for_messages
-if sys.version_info >= (3, 8):
- from typing import Literal
-else:
- from typing_extensions import Literal
-
if TYPE_CHECKING:
from pylint.lint import PyLinter
diff --git a/pylint/checkers/strings.py b/pylint/checkers/strings.py
index ce122e754..2cc780da5 100644
--- a/pylint/checkers/strings.py
+++ b/pylint/checkers/strings.py
@@ -8,11 +8,10 @@ from __future__ import annotations
import collections
import re
-import sys
import tokenize
from collections import Counter
from collections.abc import Iterable, Sequence
-from typing import TYPE_CHECKING
+from typing import TYPE_CHECKING, Literal
import astroid
from astroid import bases, nodes, util
@@ -26,11 +25,6 @@ from pylint.typing import MessageDefinitionTuple
if TYPE_CHECKING:
from pylint.lint import PyLinter
-if sys.version_info >= (3, 8):
- from typing import Literal
-else:
- from typing_extensions import Literal
-
_AST_NODE_STR_TYPES = ("__builtin__.unicode", "__builtin__.str", "builtins.str")
# Prefixes for both strings and bytes literals per
diff --git a/pylint/checkers/typecheck.py b/pylint/checkers/typecheck.py
index 0298c81dc..fe29879c5 100644
--- a/pylint/checkers/typecheck.py
+++ b/pylint/checkers/typecheck.py
@@ -14,9 +14,9 @@ import shlex
import sys
import types
from collections.abc import Callable, Iterable, Iterator, Sequence
-from functools import singledispatch
+from functools import cached_property, singledispatch
from re import Pattern
-from typing import TYPE_CHECKING, Any, TypeVar, Union
+from typing import TYPE_CHECKING, Any, Literal, TypeVar, Union
import astroid
import astroid.exceptions
@@ -53,13 +53,6 @@ from pylint.constants import PY310_PLUS
from pylint.interfaces import HIGH, INFERENCE
from pylint.typing import MessageDefinitionTuple
-if sys.version_info >= (3, 8):
- from functools import cached_property
- from typing import Literal
-else:
- from astroid.decorators import cachedproperty as cached_property
- from typing_extensions import Literal
-
if TYPE_CHECKING:
from pylint.lint import PyLinter
diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py
index 95a0e7b7b..6b66ad620 100644
--- a/pylint/checkers/utils.py
+++ b/pylint/checkers/utils.py
@@ -1942,7 +1942,7 @@ def is_typing_member(node: nodes.NodeNG, names_to_check: tuple[str, ...]) -> boo
return False
-@lru_cache()
+@lru_cache
def in_for_else_branch(parent: nodes.NodeNG, stmt: nodes.Statement) -> bool:
"""Returns True if stmt is inside the else branch for a parent For stmt."""
return isinstance(parent, nodes.For) and any(
diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py
index e1b82bb41..08797c93c 100644
--- a/pylint/checkers/variables.py
+++ b/pylint/checkers/variables.py
@@ -11,10 +11,10 @@ import copy
import itertools
import os
import re
-import sys
from collections import defaultdict
from collections.abc import Generator, Iterable, Iterator
from enum import Enum
+from functools import cached_property
from typing import TYPE_CHECKING, Any, NamedTuple
import astroid
@@ -34,11 +34,6 @@ from pylint.constants import PY39_PLUS, TYPING_NEVER, TYPING_NORETURN
from pylint.interfaces import CONTROL_FLOW, HIGH, INFERENCE, INFERENCE_FAILURE
from pylint.typing import MessageDefinitionTuple
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from astroid.decorators import cachedproperty as cached_property
-
if TYPE_CHECKING:
from pylint.lint import PyLinter