Skip to content

Commit 14f4db5

Browse files
authored
Move methods to BaseLayout (#5015)
* Move methods to `BaseLayout` and change typing, see #5004 (comment)
1 parent d4e61b9 commit 14f4db5

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

pylint/checkers/imports.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
from pylint.graph import DotBackend, get_cycles
6868
from pylint.interfaces import IAstroidChecker
6969
from pylint.lint import PyLinter
70-
from pylint.reporters.ureports.nodes import Paragraph, VerbatimText, VNode
70+
from pylint.reporters.ureports.nodes import Paragraph, Section, VerbatimText
7171
from pylint.typing import CheckerStats
7272
from pylint.utils import IsortDriver, get_global_option
7373

@@ -186,7 +186,9 @@ def _dependencies_graph(filename: str, dep_info: Dict[str, List[str]]) -> str:
186186
return printer.generate(filename)
187187

188188

189-
def _make_graph(filename: str, dep_info: Dict[str, List[str]], sect: VNode, gtype: str):
189+
def _make_graph(
190+
filename: str, dep_info: Dict[str, List[str]], sect: Section, gtype: str
191+
):
190192
"""generate a dependencies graph and add some information about it in the
191193
report's section
192194
"""

pylint/reporters/ureports/nodes.py

+9-13
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,6 @@ def __init__(self, nid=None):
2828
def __iter__(self):
2929
return iter(self.children)
3030

31-
def append(self, child):
32-
"""add a node to children"""
33-
self.children.append(child)
34-
child.parent = self
35-
36-
def insert(self, index, child):
37-
"""insert a child node"""
38-
self.children.insert(index, child)
39-
child.parent = self
40-
4131
def accept(self, visitor, *args, **kwargs):
4232
func = getattr(visitor, f"visit_{self.visitor_name}")
4333
return func(self, *args, **kwargs)
@@ -62,10 +52,16 @@ def __init__(self, children=(), **kwargs):
6252
else:
6353
self.add_text(child)
6454

65-
def append(self, child):
66-
"""overridden to detect problems easily"""
55+
def append(self, child: VNode) -> None:
56+
"""add a node to children"""
6757
assert child not in self.parents()
68-
VNode.append(self, child)
58+
self.children.append(child)
59+
child.parent = self
60+
61+
def insert(self, index: int, child: VNode) -> None:
62+
"""insert a child node"""
63+
self.children.insert(index, child)
64+
child.parent = self
6965

7066
def parents(self):
7167
"""return the ancestor nodes"""

0 commit comments

Comments
 (0)