summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>2021-09-16 08:49:24 +0200
committerGitHub <noreply@github.com>2021-09-16 08:49:24 +0200
commit14f4db56c00cd34ddd60fe9498823806abd6b3f9 (patch)
treef00d66a1b03033873c6ad2c94f07304dc423bf9c
parentd4e61b9024dd6f073739fc6f7e6ecef2dceb9aaa (diff)
downloadpylint-git-14f4db56c00cd34ddd60fe9498823806abd6b3f9.tar.gz
Move methods to `BaseLayout` (#5015)
* Move methods to `BaseLayout` and change typing, see https://github.com/PyCQA/pylint/pull/5004#discussion_r708532947
-rw-r--r--pylint/checkers/imports.py6
-rw-r--r--pylint/reporters/ureports/nodes.py22
2 files changed, 13 insertions, 15 deletions
diff --git a/pylint/checkers/imports.py b/pylint/checkers/imports.py
index 8b413253f..b8609e962 100644
--- a/pylint/checkers/imports.py
+++ b/pylint/checkers/imports.py
@@ -67,7 +67,7 @@ from pylint.exceptions import EmptyReportError
from pylint.graph import DotBackend, get_cycles
from pylint.interfaces import IAstroidChecker
from pylint.lint import PyLinter
-from pylint.reporters.ureports.nodes import Paragraph, VerbatimText, VNode
+from pylint.reporters.ureports.nodes import Paragraph, Section, VerbatimText
from pylint.typing import CheckerStats
from pylint.utils import IsortDriver, get_global_option
@@ -186,7 +186,9 @@ def _dependencies_graph(filename: str, dep_info: Dict[str, List[str]]) -> str:
return printer.generate(filename)
-def _make_graph(filename: str, dep_info: Dict[str, List[str]], sect: VNode, gtype: str):
+def _make_graph(
+ filename: str, dep_info: Dict[str, List[str]], sect: Section, gtype: str
+):
"""generate a dependencies graph and add some information about it in the
report's section
"""
diff --git a/pylint/reporters/ureports/nodes.py b/pylint/reporters/ureports/nodes.py
index c5c14737d..02887612e 100644
--- a/pylint/reporters/ureports/nodes.py
+++ b/pylint/reporters/ureports/nodes.py
@@ -28,16 +28,6 @@ class VNode:
def __iter__(self):
return iter(self.children)
- def append(self, child):
- """add a node to children"""
- self.children.append(child)
- child.parent = self
-
- def insert(self, index, child):
- """insert a child node"""
- self.children.insert(index, child)
- child.parent = self
-
def accept(self, visitor, *args, **kwargs):
func = getattr(visitor, f"visit_{self.visitor_name}")
return func(self, *args, **kwargs)
@@ -62,10 +52,16 @@ class BaseLayout(VNode):
else:
self.add_text(child)
- def append(self, child):
- """overridden to detect problems easily"""
+ def append(self, child: VNode) -> None:
+ """add a node to children"""
assert child not in self.parents()
- VNode.append(self, child)
+ self.children.append(child)
+ child.parent = self
+
+ def insert(self, index: int, child: VNode) -> None:
+ """insert a child node"""
+ self.children.insert(index, child)
+ child.parent = self
def parents(self):
"""return the ancestor nodes"""