From 0687d5caf7a57ebf9c82126e92a3c223d724f5b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Tue, 14 Sep 2021 23:03:02 +0200 Subject: [PATCH 1/2] Change lines to lists (#5009) --- pylint/checkers/base.py | 6 +++--- pylint/checkers/raw_metrics.py | 4 ++-- pylint/lint/report_functions.py | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pylint/checkers/base.py b/pylint/checkers/base.py index 2ca79453a79..d839d921e19 100644 --- a/pylint/checkers/base.py +++ b/pylint/checkers/base.py @@ -412,7 +412,7 @@ def report_by_type_stats(sect, stats, old_stats): nice_stats[node_type]["percent_badname"] = f"{percent:.2f}" except KeyError: nice_stats[node_type]["percent_badname"] = "NC" - lines = ("type", "number", "old number", "difference", "%documented", "%badname") + lines = ["type", "number", "old number", "difference", "%documented", "%badname"] for node_type in ("module", "class", "method", "function"): new = stats[node_type] old = old_stats.get(node_type, None) @@ -420,14 +420,14 @@ def report_by_type_stats(sect, stats, old_stats): diff_str = lint_utils.diff_string(old, new) else: old, diff_str = "NC", "NC" - lines += ( + lines += [ node_type, str(new), str(old), diff_str, nice_stats[node_type].get("percent_documented", "0"), nice_stats[node_type].get("percent_badname", "0"), - ) + ] sect.append(reporter_nodes.Table(children=lines, cols=6, rheaders=1)) diff --git a/pylint/checkers/raw_metrics.py b/pylint/checkers/raw_metrics.py index eb3f717ff16..028c68e7aba 100644 --- a/pylint/checkers/raw_metrics.py +++ b/pylint/checkers/raw_metrics.py @@ -30,7 +30,7 @@ def report_raw_stats(sect, stats, old_stats): if not total_lines: raise EmptyReportError() sect.description = f"{total_lines} lines have been analyzed" - lines = ("type", "number", "%", "previous", "difference") + lines = ["type", "number", "%", "previous", "difference"] for node_type in ("code", "docstring", "comment", "empty"): key = node_type + "_lines" total = stats[key] @@ -40,7 +40,7 @@ def report_raw_stats(sect, stats, old_stats): diff_str = diff_string(old, total) else: old, diff_str = "NC", "NC" - lines += (node_type, str(total), f"{percent:.2f}", str(old), diff_str) + lines += [node_type, str(total), f"{percent:.2f}", str(old), diff_str] sect.append(Table(children=lines, cols=5, rheaders=1)) diff --git a/pylint/lint/report_functions.py b/pylint/lint/report_functions.py index fd316c611f7..21cb3b8245d 100644 --- a/pylint/lint/report_functions.py +++ b/pylint/lint/report_functions.py @@ -27,9 +27,9 @@ def report_messages_stats(sect, stats, _): if not msg_id.startswith("I") ) in_order.reverse() - lines = ("message id", "occurrences") + lines = ["message id", "occurrences"] for value, msg_id in in_order: - lines += (msg_id, str(value)) + lines += [msg_id, str(value)] sect.append(report_nodes.Table(children=lines, cols=2, rheaders=1)) From a3f3405d57558d6d5dd21112a5dfeb1fb1ed50a5 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Wed, 15 Sep 2021 07:43:05 +0200 Subject: [PATCH 2/2] Fix PyreverseConfig imports in pyreverse's tests --- setup.cfg | 3 +++ tests/pyreverse/test_diadefs.py | 2 +- tests/pyreverse/test_writer.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index 7e18ba310cf..f415db45d47 100644 --- a/setup.cfg +++ b/setup.cfg @@ -89,6 +89,9 @@ warn_unused_ignores = True [mypy-astroid.*] ignore_missing_imports = True +[mypy-tests.*] +ignore_missing_imports = True + [mypy-coverage] ignore_missing_imports = True diff --git a/tests/pyreverse/test_diadefs.py b/tests/pyreverse/test_diadefs.py index 3c2ab7fda98..622ad59eb18 100644 --- a/tests/pyreverse/test_diadefs.py +++ b/tests/pyreverse/test_diadefs.py @@ -26,7 +26,7 @@ import pytest from astroid import nodes -from conftest import PyreverseConfig # type: ignore #pylint: disable=no-name-in-module +from tests.pyreverse.conftest import PyreverseConfig from pylint.pyreverse.diadefslib import ( ClassDiadefGenerator, diff --git a/tests/pyreverse/test_writer.py b/tests/pyreverse/test_writer.py index 9c847be2994..e0bcfaaa40b 100644 --- a/tests/pyreverse/test_writer.py +++ b/tests/pyreverse/test_writer.py @@ -28,7 +28,7 @@ from unittest.mock import Mock import pytest -from conftest import PyreverseConfig # type: ignore #pylint: disable=no-name-in-module +from tests.pyreverse.conftest import PyreverseConfig from pylint.pyreverse.diadefslib import DefaultDiadefGenerator, DiadefsHandler from pylint.pyreverse.inspector import Linker, Project