Skip to content

Commit

Permalink
Merge ce75070 into d4e61b9
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielNoord committed Sep 15, 2021
2 parents d4e61b9 + ce75070 commit 5f84292
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
6 changes: 4 additions & 2 deletions pylint/checkers/imports.py
Expand Up @@ -67,7 +67,7 @@
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

Expand Down Expand Up @@ -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
"""
Expand Down
22 changes: 9 additions & 13 deletions pylint/reporters/ureports/nodes.py
Expand Up @@ -28,16 +28,6 @@ def __init__(self, nid=None):
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)
Expand All @@ -62,10 +52,16 @@ def __init__(self, children=(), **kwargs):
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"""
Expand Down

0 comments on commit 5f84292

Please sign in to comment.