From 7195d9077e1ed1befff5b7d47962f52b97bb3c88 Mon Sep 17 00:00:00 2001 From: Gemini Date: Tue, 30 Jun 2026 13:03:26 -0400 Subject: [PATCH] fix: remove stray newlines from inheritance printer --- slither/printers/inheritance/inheritance.py | 17 ++++++++--------- tests/e2e/printers/test_printers.py | 2 ++ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/slither/printers/inheritance/inheritance.py b/slither/printers/inheritance/inheritance.py index 6389301c4f..3ebf62dc18 100644 --- a/slither/printers/inheritance/inheritance.py +++ b/slither/printers/inheritance/inheritance.py @@ -36,27 +36,27 @@ def output(self, filename): result = {"child_to_base": {}, "paths": {}} for child in self.contracts: - info += blue(f"\n+ {child.name}") + info += blue(f"\n+ {child.name}\n") result["paths"][child.name] = child.source_mapping.filename.absolute result["child_to_base"][child.name] = {"immediate": [], "not_immediate": []} if child.inheritance: immediate = child.immediate_inheritance not_immediate = [i for i in child.inheritance if i not in immediate] - info += " -> " + green(", ".join(map(str, immediate))) + info += " -> " + green(", ".join(map(str, immediate))) + "\n" result["child_to_base"][child.name]["immediate"] = list(map(str, immediate)) if not_immediate: - info += ", [" + green(", ".join(map(str, not_immediate))) + "]" + info += ", [" + green(", ".join(map(str, not_immediate))) + "]\n" result["child_to_base"][child.name]["not_immediate"] = list( map(str, not_immediate) ) - info += green("\n\nBase_Contract -> ") + blue("Immediate_Child_Contracts") - info += blue(" [Not_Immediate_Child_Contracts]") + info += green("\n\nBase_Contract -> ") + blue("Immediate_Child_Contracts") + "\n" + info += blue(" [Not_Immediate_Child_Contracts]") + "\n" result["base_to_child"] = {} for base in self.contracts: - info += green(f"\n+ {base.name}") + info += green(f"\n+ {base.name}") + "\n" children = list(self._get_child_contracts(base)) result["base_to_child"][base.name] = {"immediate": [], "not_immediate": []} @@ -64,15 +64,14 @@ def output(self, filename): immediate = [child for child in children if base in child.immediate_inheritance] not_immediate = [child for child in children if child not in immediate] - info += " -> " + blue(", ".join(map(str, immediate))) + info += " -> " + blue(", ".join(map(str, immediate))) + "\n" result["base_to_child"][base.name]["immediate"] = list(map(str, immediate)) if not_immediate: - info += ", [" + blue(", ".join(map(str, not_immediate))) + "]" + info += ", [" + blue(", ".join(map(str, not_immediate))) + "]\n" result["base_to_child"][base.name]["not_immediate"] = list( map(str, not_immediate) ) - info += "\n" self.info(info) res = self.generate_output(info, additional_fields=result) diff --git a/tests/e2e/printers/test_printers.py b/tests/e2e/printers/test_printers.py index 8d9d15f603..bb0fd99122 100644 --- a/tests/e2e/printers/test_printers.py +++ b/tests/e2e/printers/test_printers.py @@ -106,6 +106,8 @@ def test_inheritance_text_printer(solc_binary_path) -> None: output = printer.output("test_inheritance.txt") # Data is nested under additional_fields + assert "\r" not in output.data["description"] + data = output.data["additional_fields"] # Verify JSON structure has expected keys