Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move methods to BaseLayout #5015

Merged
merged 2 commits into from Sep 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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