From 286e94f0f5431263353ebe7df9f76099d3877bab Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Wed, 15 Dec 2021 18:26:02 +0100 Subject: [PATCH] Upgrade pylint to 2.12.2 (#1297) * Upgrade pylint to 2.12.2 * Default Python in the CI is now python 3.8 * Remove useless suppression for python 3.8 * Disable no-member for false positive with zipimport --- .github/workflows/ci.yaml | 2 +- astroid/interpreter/_import/spec.py | 1 + astroid/manager.py | 2 +- astroid/nodes/node_ng.py | 10 +++++++++- requirements_test_pre_commit.txt | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d3a0962d0b..a7700fb808 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,7 +9,7 @@ on: env: CACHE_VERSION: 3 - DEFAULT_PYTHON: 3.6 + DEFAULT_PYTHON: 3.8 PRE_COMMIT_CACHE: ~/.cache/pre-commit jobs: diff --git a/astroid/interpreter/_import/spec.py b/astroid/interpreter/_import/spec.py index aad9c51c78..43f00153a3 100644 --- a/astroid/interpreter/_import/spec.py +++ b/astroid/interpreter/_import/spec.py @@ -292,6 +292,7 @@ def _precache_zipimporters(path=None): req_paths = tuple(path or sys.path) cached_paths = tuple(pic) new_paths = _cached_set_diff(req_paths, cached_paths) + # pylint: disable=no-member for entry_path in new_paths: try: pic[entry_path] = zipimport.zipimporter(entry_path) diff --git a/astroid/manager.py b/astroid/manager.py index 36740fc729..ed0c31544a 100644 --- a/astroid/manager.py +++ b/astroid/manager.py @@ -234,8 +234,8 @@ def zip_import_data(self, filepath): except ValueError: continue try: + # pylint: disable-next=no-member importer = zipimport.zipimporter(eggpath + ext) - # pylint: enable=no-member zmodname = resource.replace(os.path.sep, ".") if importer.is_package(resource): zmodname = zmodname + ".__init__" diff --git a/astroid/nodes/node_ng.py b/astroid/nodes/node_ng.py index 150860e226..64a750f884 100644 --- a/astroid/nodes/node_ng.py +++ b/astroid/nodes/node_ng.py @@ -29,6 +29,14 @@ from astroid.nodes.as_string import AsStringVisitor from astroid.nodes.const import OP_PRECEDENCE +if TYPE_CHECKING: + from astroid import nodes + + if sys.version_info >= (3, 6, 2): + from typing import NoReturn + else: + from typing_extensions import NoReturn + if sys.version_info >= (3, 8): from typing import Literal else: @@ -448,7 +456,7 @@ def _fixed_source_line(self) -> Optional[int]: We need this method since not all nodes have :attr:`lineno` set. """ line = self.lineno - _node: Optional[NodeNG] = self # pylint: disable = used-before-assignment + _node: Optional[NodeNG] = self try: while line is None: _node = next(_node.get_children()) diff --git a/requirements_test_pre_commit.txt b/requirements_test_pre_commit.txt index c5ab3d58f7..b08f5bc544 100644 --- a/requirements_test_pre_commit.txt +++ b/requirements_test_pre_commit.txt @@ -1,5 +1,5 @@ black==21.7b0 -pylint==2.12.1 +pylint==2.12.2 isort==5.9.2 flake8==4.0.1 flake8-typing-imports==1.11.0