From daf4f1af5c04639f98e36c593667032dc23679ab Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Mon, 2 Aug 2021 12:21:02 +0200 Subject: [PATCH] Update pylint to 2.9.6 (#1114) * Update pylint to v2.9.6 * Code updates --- astroid/node_classes.py | 3 +-- astroid/protocols.py | 5 ++--- astroid/rebuilder.py | 1 - requirements_test_pre_commit.txt | 2 +- script/bump_changelog.py | 2 +- tests/unittest_manager.py | 2 +- tests/unittest_modutils.py | 2 +- tests/unittest_nodes.py | 6 +++--- 8 files changed, 10 insertions(+), 13 deletions(-) diff --git a/astroid/node_classes.py b/astroid/node_classes.py index 00c1f33485..81e6f1f143 100644 --- a/astroid/node_classes.py +++ b/astroid/node_classes.py @@ -57,7 +57,6 @@ from astroid.manager import AstroidManager if sys.version_info >= (3, 8): - # pylint: disable=no-name-in-module from typing import Literal else: from typing_extensions import Literal @@ -611,7 +610,7 @@ def tolineno(self) -> Optional[int]: if last_child is None: return self.fromlineno - return last_child.tolineno # pylint: disable=no-member + return last_child.tolineno def _fixed_source_line(self) -> Optional[int]: """Attempt to find the line that this node appears on. diff --git a/astroid/protocols.py b/astroid/protocols.py index ec36611e40..fb4cabcbde 100644 --- a/astroid/protocols.py +++ b/astroid/protocols.py @@ -46,7 +46,6 @@ ) if sys.version_info >= (3, 8): - # pylint: disable=no-name-in-module from typing import Literal else: from typing_extensions import Literal @@ -796,7 +795,7 @@ def match_mapping_assigned_stmts( is Uninferable. """ return - yield # pylint: disable=unreachable + yield nodes.MatchMapping.assigned_stmts = match_mapping_assigned_stmts @@ -813,7 +812,7 @@ def match_star_assigned_stmts( is Uninferable. """ return - yield # pylint: disable=unreachable + yield nodes.MatchStar.assigned_stmts = match_star_assigned_stmts diff --git a/astroid/rebuilder.py b/astroid/rebuilder.py index e53b427a8f..92988bdeaa 100644 --- a/astroid/rebuilder.py +++ b/astroid/rebuilder.py @@ -52,7 +52,6 @@ from astroid.node_classes import NodeNG if sys.version_info >= (3, 8): - # pylint: disable=no-name-in-module from typing import Final else: from typing_extensions import Final diff --git a/requirements_test_pre_commit.txt b/requirements_test_pre_commit.txt index ab46ead0f1..d5ee97b6e5 100644 --- a/requirements_test_pre_commit.txt +++ b/requirements_test_pre_commit.txt @@ -1,5 +1,5 @@ black==21.7b0 -pylint==2.9.3 +pylint==2.9.6 isort==5.9.2 flake8==3.9.2 mypy==0.910 diff --git a/script/bump_changelog.py b/script/bump_changelog.py index be8d00a1be..2745d0ce9f 100644 --- a/script/bump_changelog.py +++ b/script/bump_changelog.py @@ -30,7 +30,7 @@ def main() -> None: logging.debug(f"Launching bump_changelog with args: {args}") if "dev" in args.version: return - with open(DEFAULT_CHANGELOG_PATH) as f: + with open(DEFAULT_CHANGELOG_PATH, encoding="utf-8") as f: content = f.read() content = transform_content(content, args.version) with open(DEFAULT_CHANGELOG_PATH, "w") as f: diff --git a/tests/unittest_manager.py b/tests/unittest_manager.py index bb12847417..2bed335b69 100644 --- a/tests/unittest_manager.py +++ b/tests/unittest_manager.py @@ -79,7 +79,7 @@ def test_ast_from_string(self): filepath = unittest.__file__ dirname = os.path.dirname(filepath) modname = os.path.basename(dirname) - with open(filepath) as file: + with open(filepath, encoding="utf-8") as file: data = file.read() ast = self.manager.ast_from_string(data, modname, filepath) self.assertEqual(ast.name, "unittest") diff --git a/tests/unittest_modutils.py b/tests/unittest_modutils.py index 254ada24a4..13268f4c18 100644 --- a/tests/unittest_modutils.py +++ b/tests/unittest_modutils.py @@ -181,7 +181,7 @@ def test_load_from_module_symlink_on_symlinked_paths_in_syspath(self): self.addCleanup(os.remove, path_to_include) except OSError: pass - with open(real_secret_path, "w"): + with open(real_secret_path, "w", encoding="utf-8"): pass os.symlink(real_secret_path, symlink_secret_path) self.addCleanup(os.remove, real_secret_path) diff --git a/tests/unittest_nodes.py b/tests/unittest_nodes.py index 60909bf23f..d935c4874a 100644 --- a/tests/unittest_nodes.py +++ b/tests/unittest_nodes.py @@ -117,13 +117,13 @@ def test_varargs_kwargs_as_string(self): def test_module_as_string(self): """check as_string on a whole module prepared to be returned identically""" module = resources.build_file("data/module.py", "data.module") - with open(resources.find("data/module.py")) as fobj: + with open(resources.find("data/module.py"), encoding="utf-8") as fobj: self.assertMultiLineEqual(module.as_string(), fobj.read()) def test_module2_as_string(self): """check as_string on a whole module prepared to be returned identically""" module2 = resources.build_file("data/module2.py", "data.module2") - with open(resources.find("data/module2.py")) as fobj: + with open(resources.find("data/module2.py"), encoding="utf-8") as fobj: self.assertMultiLineEqual(module2.as_string(), fobj.read()) def test_as_string(self): @@ -215,7 +215,7 @@ def test_int_attribute(self): self.assertEqual(ast.as_string().strip(), code.strip()) def test_operator_precedence(self): - with open(resources.find("data/operator_precedence.py")) as f: + with open(resources.find("data/operator_precedence.py"), encoding="utf-8") as f: for code in f: self.check_as_string_ast_equality(code)