From 87fb412ea0e87dceeceb7ff8c20a76a556da363a Mon Sep 17 00:00:00 2001 From: bohendo Date: Mon, 27 Jan 2025 15:42:13 -0500 Subject: [PATCH] fix formatting --- slither/core/source_mapping/source_mapping.py | 6 +++++- slither/tools/mutator/mutators/AOR.py | 2 +- slither/tools/mutator/mutators/BOR.py | 2 +- slither/tools/mutator/mutators/RR.py | 7 +++++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/slither/core/source_mapping/source_mapping.py b/slither/core/source_mapping/source_mapping.py index 61545c8f5..59d59ad11 100644 --- a/slither/core/source_mapping/source_mapping.py +++ b/slither/core/source_mapping/source_mapping.py @@ -79,7 +79,11 @@ def content(self) -> str: # If the compilation unit was not initialized, it means that the set_offset was never called # on the corresponding object, which should not happen assert self.compilation_unit - return self.compilation_unit.core.source_code[self.filename.absolute].encode("utf-8")[self.start : self.end].decode("utf-8") + return ( + self.compilation_unit.core.source_code[self.filename.absolute] + .encode("utf-8")[self.start : self.end] + .decode("utf-8") + ) @property def content_hash(self) -> str: diff --git a/slither/tools/mutator/mutators/AOR.py b/slither/tools/mutator/mutators/AOR.py index a9e816f9e..1e9008efe 100644 --- a/slither/tools/mutator/mutators/AOR.py +++ b/slither/tools/mutator/mutators/AOR.py @@ -79,7 +79,7 @@ def _mutate(self) -> Dict: if not line_no[0] in self.dont_mutate_line: halves = old_str.split(ir.type.value) if len(halves) != 2: - continue # skip if assembly + continue # skip if assembly new_str = f"{halves[0]}{op.value}{halves[1]}" create_patch_with_line( result, diff --git a/slither/tools/mutator/mutators/BOR.py b/slither/tools/mutator/mutators/BOR.py index d6638daf8..2926cf1c0 100644 --- a/slither/tools/mutator/mutators/BOR.py +++ b/slither/tools/mutator/mutators/BOR.py @@ -37,7 +37,7 @@ def _mutate(self) -> Dict: # Replace the expression with true halves = old_str.split(ir.type.value) if len(halves) != 2: - continue # skip if assembly + continue # skip if assembly new_str = f"{halves[0]}{op.value}{halves[1]}" create_patch_with_line( result, diff --git a/slither/tools/mutator/mutators/RR.py b/slither/tools/mutator/mutators/RR.py index 174daa671..1bcc12e40 100644 --- a/slither/tools/mutator/mutators/RR.py +++ b/slither/tools/mutator/mutators/RR.py @@ -3,6 +3,7 @@ from slither.tools.mutator.utils.patch import create_patch_with_line from slither.tools.mutator.mutators.abstract_mutator import AbstractMutator + class RR(AbstractMutator): # pylint: disable=too-few-public-methods NAME = "RR" HELP = "Revert Replacement" @@ -25,8 +26,10 @@ def _mutate(self) -> Dict: old_str = node.source_mapping.content line_no = node.source_mapping.lines[0] if not line_no in self.dont_mutate_line: - if node.type == NodeType.RETURN and not old_str.lstrip().startswith("return"): - continue # skip the return declarations in fn signatures + if node.type == NodeType.RETURN and not old_str.lstrip().startswith( + "return" + ): + continue # skip the return declarations in fn signatures if not old_str.lstrip().startswith("revert"): new_str = "revert()" create_patch_with_line(