diff --git a/__init__.py b/__init__.py index 136a0e008..7c43afacd 100644 --- a/__init__.py +++ b/__init__.py @@ -1,4 +1,5 @@ """Main plugin file registering plugin commands in bianryninja.""" + from logging import info, warning from os.path import dirname, realpath from sys import path diff --git a/decompiler/backend/codegenerator.py b/decompiler/backend/codegenerator.py index 827fdedfe..ebb31c61c 100644 --- a/decompiler/backend/codegenerator.py +++ b/decompiler/backend/codegenerator.py @@ -1,4 +1,5 @@ """Module in charge of bundling all classes utilized to generate c-code from an AST.""" + from string import Template from typing import Iterable, List diff --git a/decompiler/backend/variabledeclarations.py b/decompiler/backend/variabledeclarations.py index fb53b8ac9..d4102791b 100644 --- a/decompiler/backend/variabledeclarations.py +++ b/decompiler/backend/variabledeclarations.py @@ -1,4 +1,5 @@ """Module containing the visitors used to generate variable declarations.""" + from collections import defaultdict from typing import Iterable, Iterator, List diff --git a/decompiler/frontend/__init__.py b/decompiler/frontend/__init__.py index 7e19986f8..72f765c7e 100644 --- a/decompiler/frontend/__init__.py +++ b/decompiler/frontend/__init__.py @@ -1,4 +1,5 @@ """module for anything pipeline related.""" + from .binaryninja.frontend import BinaryninjaFrontend from .frontend import Frontend from .lifter import Lifter diff --git a/decompiler/frontend/binaryninja/frontend.py b/decompiler/frontend/binaryninja/frontend.py index 8c5fe8dc8..e84697fc7 100644 --- a/decompiler/frontend/binaryninja/frontend.py +++ b/decompiler/frontend/binaryninja/frontend.py @@ -1,4 +1,5 @@ """Class implementing the main binaryninja frontend interface.""" + from __future__ import annotations import logging diff --git a/decompiler/frontend/binaryninja/handlers/__init__.py b/decompiler/frontend/binaryninja/handlers/__init__.py index e5917facb..d78338fa6 100644 --- a/decompiler/frontend/binaryninja/handlers/__init__.py +++ b/decompiler/frontend/binaryninja/handlers/__init__.py @@ -1,4 +1,5 @@ """Main module containing all binaryninja handlers.""" + from .assignments import AssignmentHandler from .binary import BinaryOperationHandler from .calls import CallHandler diff --git a/decompiler/frontend/binaryninja/handlers/assignments.py b/decompiler/frontend/binaryninja/handlers/assignments.py index 306336a5e..a751cd365 100644 --- a/decompiler/frontend/binaryninja/handlers/assignments.py +++ b/decompiler/frontend/binaryninja/handlers/assignments.py @@ -1,4 +1,5 @@ """Module implementing the AssignmentHandler for binaryninja.""" + import logging from functools import partial diff --git a/decompiler/frontend/binaryninja/handlers/binary.py b/decompiler/frontend/binaryninja/handlers/binary.py index cdd3eab6c..55076ff95 100644 --- a/decompiler/frontend/binaryninja/handlers/binary.py +++ b/decompiler/frontend/binaryninja/handlers/binary.py @@ -1,4 +1,5 @@ """Module implementing the handler for binaryninja's binary operations.""" + from functools import partial from binaryninja import MediumLevelILInstruction, mediumlevelil diff --git a/decompiler/frontend/binaryninja/handlers/calls.py b/decompiler/frontend/binaryninja/handlers/calls.py index 18af28b8b..a7d9ec930 100644 --- a/decompiler/frontend/binaryninja/handlers/calls.py +++ b/decompiler/frontend/binaryninja/handlers/calls.py @@ -1,4 +1,5 @@ """Module implementing the binaryninja CallHandler.""" + from functools import partial from typing import List diff --git a/decompiler/frontend/binaryninja/handlers/conditions.py b/decompiler/frontend/binaryninja/handlers/conditions.py index 81cc25bc9..00e6fab98 100644 --- a/decompiler/frontend/binaryninja/handlers/conditions.py +++ b/decompiler/frontend/binaryninja/handlers/conditions.py @@ -1,4 +1,5 @@ """Module implementing the ConditionHandler class.""" + from functools import partial from binaryninja import mediumlevelil diff --git a/decompiler/frontend/binaryninja/handlers/constants.py b/decompiler/frontend/binaryninja/handlers/constants.py index 295b89ff4..ce434e673 100644 --- a/decompiler/frontend/binaryninja/handlers/constants.py +++ b/decompiler/frontend/binaryninja/handlers/constants.py @@ -1,4 +1,5 @@ """Module implementing the ConstantHandler for the binaryninja frontend.""" + import math from binaryninja import BinaryView, DataVariable, SectionSemantics, SymbolType, Type, mediumlevelil diff --git a/decompiler/frontend/binaryninja/handlers/controlflow.py b/decompiler/frontend/binaryninja/handlers/controlflow.py index 35c7af6ec..6729dcea6 100644 --- a/decompiler/frontend/binaryninja/handlers/controlflow.py +++ b/decompiler/frontend/binaryninja/handlers/controlflow.py @@ -1,4 +1,5 @@ """Module implementing the ConditionHandler class.""" + from binaryninja import mediumlevelil from decompiler.frontend.lifter import Handler from decompiler.structures.pseudo import Branch, Condition, Constant, IndirectBranch, OperationType, Return diff --git a/decompiler/frontend/binaryninja/handlers/globals.py b/decompiler/frontend/binaryninja/handlers/globals.py index 50e54af77..175f3b5a0 100644 --- a/decompiler/frontend/binaryninja/handlers/globals.py +++ b/decompiler/frontend/binaryninja/handlers/globals.py @@ -1,4 +1,5 @@ """Module implementing the ConstantHandler for the binaryninja frontend.""" + from typing import Callable, Optional, Tuple, Union from binaryninja import BinaryView, DataVariable, Endianness, MediumLevelILInstruction, Type diff --git a/decompiler/frontend/binaryninja/handlers/phi.py b/decompiler/frontend/binaryninja/handlers/phi.py index 87b71679f..eb4cfc9d0 100644 --- a/decompiler/frontend/binaryninja/handlers/phi.py +++ b/decompiler/frontend/binaryninja/handlers/phi.py @@ -1,4 +1,5 @@ """Module implementing lifting of phi and memphi instructions.""" + from typing import List from binaryninja import MediumLevelILMemPhi, MediumLevelILVarPhi diff --git a/decompiler/frontend/binaryninja/handlers/symbols.py b/decompiler/frontend/binaryninja/handlers/symbols.py index dfe78b576..29825c0e5 100644 --- a/decompiler/frontend/binaryninja/handlers/symbols.py +++ b/decompiler/frontend/binaryninja/handlers/symbols.py @@ -1,4 +1,5 @@ """Module implementing lifting of binaryninja symbols.""" + from logging import warning from typing import Union diff --git a/decompiler/frontend/binaryninja/handlers/unary.py b/decompiler/frontend/binaryninja/handlers/unary.py index 4bc0a089c..873158a4f 100644 --- a/decompiler/frontend/binaryninja/handlers/unary.py +++ b/decompiler/frontend/binaryninja/handlers/unary.py @@ -1,4 +1,5 @@ """Module implementing the UnaryOperationHandler.""" + import logging from functools import partial from typing import Union diff --git a/decompiler/frontend/binaryninja/handlers/variables.py b/decompiler/frontend/binaryninja/handlers/variables.py index 1620bd73c..ac4bc0a30 100644 --- a/decompiler/frontend/binaryninja/handlers/variables.py +++ b/decompiler/frontend/binaryninja/handlers/variables.py @@ -1,4 +1,5 @@ """Module implementing variable lifting for the binaryninja observer lifer.""" + from typing import Optional from binaryninja import ( diff --git a/decompiler/frontend/binaryninja/lifter.py b/decompiler/frontend/binaryninja/lifter.py index 244df6ed4..ebe8cfefd 100644 --- a/decompiler/frontend/binaryninja/lifter.py +++ b/decompiler/frontend/binaryninja/lifter.py @@ -1,4 +1,5 @@ """Module implementing the BinaryNinjaLifter of the binaryninja frontend.""" + from logging import warning from typing import Optional, Tuple, Union diff --git a/decompiler/frontend/binaryninja/parser.py b/decompiler/frontend/binaryninja/parser.py index 119804475..353514b03 100644 --- a/decompiler/frontend/binaryninja/parser.py +++ b/decompiler/frontend/binaryninja/parser.py @@ -1,4 +1,5 @@ """Implements the parser for the binaryninja frontend.""" + from logging import info, warning from typing import Dict, Iterator, List, Tuple diff --git a/decompiler/frontend/binaryninja/tests.py b/decompiler/frontend/binaryninja/tests.py index adfb8567c..7181c6cc4 100644 --- a/decompiler/frontend/binaryninja/tests.py +++ b/decompiler/frontend/binaryninja/tests.py @@ -1,4 +1,5 @@ """WIP test suite for binaryninja lifter.""" + from os import listdir from os.path import abspath, dirname, isfile, join, realpath from sys import path diff --git a/decompiler/frontend/frontend.py b/decompiler/frontend/frontend.py index 3dd29c5da..c5b57d8fd 100644 --- a/decompiler/frontend/frontend.py +++ b/decompiler/frontend/frontend.py @@ -1,4 +1,5 @@ """Module implementing the interface for different frontends.""" + from __future__ import annotations from abc import ABC, abstractmethod diff --git a/decompiler/frontend/lifter.py b/decompiler/frontend/lifter.py index c58e76382..783ab49c1 100644 --- a/decompiler/frontend/lifter.py +++ b/decompiler/frontend/lifter.py @@ -1,4 +1,5 @@ """Interface for frontend lifters.""" + from abc import ABC, abstractmethod from typing import Callable, Dict, Type, TypeVar diff --git a/decompiler/frontend/parser.py b/decompiler/frontend/parser.py index fdaef6ca7..521294e4a 100644 --- a/decompiler/frontend/parser.py +++ b/decompiler/frontend/parser.py @@ -1,4 +1,5 @@ """Module defining the parser interface.""" + from abc import ABC, abstractmethod from decompiler.structures.graphs.cfg import ControlFlowGraph diff --git a/decompiler/logger.py b/decompiler/logger.py index a25502164..d15d5b0b5 100644 --- a/decompiler/logger.py +++ b/decompiler/logger.py @@ -1,4 +1,5 @@ """Module in charge of logger initialization and settings.""" + import logging.config from typing import Optional diff --git a/decompiler/pipeline/commons/livenessanalysis.py b/decompiler/pipeline/commons/livenessanalysis.py index 3afad2e46..5159438af 100644 --- a/decompiler/pipeline/commons/livenessanalysis.py +++ b/decompiler/pipeline/commons/livenessanalysis.py @@ -1,4 +1,5 @@ """Liveness Analysis due to Brandner et al. : Algorithms 4 (Compute liveness sets by exploring paths from variable uses""" + from collections import defaultdict from typing import DefaultDict diff --git a/decompiler/pipeline/controlflowanalysis/expression_simplification/constant_folding.py b/decompiler/pipeline/controlflowanalysis/expression_simplification/constant_folding.py index 13f345cb7..31656b667 100644 --- a/decompiler/pipeline/controlflowanalysis/expression_simplification/constant_folding.py +++ b/decompiler/pipeline/controlflowanalysis/expression_simplification/constant_folding.py @@ -17,7 +17,6 @@ class UnsupportedOperationType(Exception): class UnsupportedValueType(Exception): - """Indicates that the value type of one constant is not supported.""" pass diff --git a/decompiler/pipeline/controlflowanalysis/readability_based_refinement.py b/decompiler/pipeline/controlflowanalysis/readability_based_refinement.py index f979803c7..ee5698a33 100644 --- a/decompiler/pipeline/controlflowanalysis/readability_based_refinement.py +++ b/decompiler/pipeline/controlflowanalysis/readability_based_refinement.py @@ -1,4 +1,5 @@ """Module implementing various readability based refinements.""" + from __future__ import annotations from typing import Union diff --git a/decompiler/pipeline/controlflowanalysis/restructuring.py b/decompiler/pipeline/controlflowanalysis/restructuring.py index cc3cb7789..949e3e41c 100644 --- a/decompiler/pipeline/controlflowanalysis/restructuring.py +++ b/decompiler/pipeline/controlflowanalysis/restructuring.py @@ -1,6 +1,7 @@ """ Module for pattern independent restructuring """ + from __future__ import annotations import logging diff --git a/decompiler/pipeline/controlflowanalysis/restructuring_commons/ast_processor.py b/decompiler/pipeline/controlflowanalysis/restructuring_commons/ast_processor.py index a88cb25c3..8edf915e6 100644 --- a/decompiler/pipeline/controlflowanalysis/restructuring_commons/ast_processor.py +++ b/decompiler/pipeline/controlflowanalysis/restructuring_commons/ast_processor.py @@ -1,4 +1,5 @@ """Module for AST processing steps.""" + import logging from typing import Callable, Dict, Iterable, List, Optional, Set, Tuple, Union diff --git a/decompiler/pipeline/controlflowanalysis/restructuring_commons/condition_based_refinement.py b/decompiler/pipeline/controlflowanalysis/restructuring_commons/condition_based_refinement.py index 2cab9c905..e05911b03 100644 --- a/decompiler/pipeline/controlflowanalysis/restructuring_commons/condition_based_refinement.py +++ b/decompiler/pipeline/controlflowanalysis/restructuring_commons/condition_based_refinement.py @@ -1,6 +1,7 @@ """ Module for Condition Based Refinement """ + from itertools import combinations from typing import Iterator, List, Optional, Set, Tuple diff --git a/decompiler/pipeline/controlflowanalysis/restructuring_commons/graphslice.py b/decompiler/pipeline/controlflowanalysis/restructuring_commons/graphslice.py index ca545d94b..778bc6fd0 100644 --- a/decompiler/pipeline/controlflowanalysis/restructuring_commons/graphslice.py +++ b/decompiler/pipeline/controlflowanalysis/restructuring_commons/graphslice.py @@ -1,4 +1,5 @@ """Module to compute graph slices.""" + from __future__ import annotations from typing import Iterator, List, Set diff --git a/decompiler/pipeline/controlflowanalysis/restructuring_commons/loop_structurer.py b/decompiler/pipeline/controlflowanalysis/restructuring_commons/loop_structurer.py index 073f53789..bf03cbccb 100644 --- a/decompiler/pipeline/controlflowanalysis/restructuring_commons/loop_structurer.py +++ b/decompiler/pipeline/controlflowanalysis/restructuring_commons/loop_structurer.py @@ -1,4 +1,5 @@ """Module to structure Loops""" + from typing import Optional from decompiler.pipeline.controlflowanalysis.restructuring_commons.ast_processor import LoopProcessor diff --git a/decompiler/pipeline/controlflowanalysis/restructuring_commons/region_finder/acyclic_region_finder.py b/decompiler/pipeline/controlflowanalysis/restructuring_commons/region_finder/acyclic_region_finder.py index 2b0abac56..d2593ed4a 100644 --- a/decompiler/pipeline/controlflowanalysis/restructuring_commons/region_finder/acyclic_region_finder.py +++ b/decompiler/pipeline/controlflowanalysis/restructuring_commons/region_finder/acyclic_region_finder.py @@ -1,4 +1,5 @@ """Module to find restructurable regions.""" + from __future__ import annotations from abc import abstractmethod diff --git a/decompiler/pipeline/dataflowanalysis/array_access_detection.py b/decompiler/pipeline/dataflowanalysis/array_access_detection.py index 2283ad735..1a5826a39 100644 --- a/decompiler/pipeline/dataflowanalysis/array_access_detection.py +++ b/decompiler/pipeline/dataflowanalysis/array_access_detection.py @@ -1,4 +1,5 @@ """Module implementing detection of array element accesses""" + import logging from collections import defaultdict from dataclasses import dataclass, field diff --git a/decompiler/pipeline/dataflowanalysis/common_subexpression_elimination.py b/decompiler/pipeline/dataflowanalysis/common_subexpression_elimination.py index 60f64f332..03c2ce2ca 100644 --- a/decompiler/pipeline/dataflowanalysis/common_subexpression_elimination.py +++ b/decompiler/pipeline/dataflowanalysis/common_subexpression_elimination.py @@ -1,4 +1,5 @@ """Module implementing common subexpression elimination.""" + from __future__ import annotations from collections import defaultdict, deque diff --git a/decompiler/pipeline/dataflowanalysis/dead_loop_elimination.py b/decompiler/pipeline/dataflowanalysis/dead_loop_elimination.py index c391fd861..be8f40f78 100644 --- a/decompiler/pipeline/dataflowanalysis/dead_loop_elimination.py +++ b/decompiler/pipeline/dataflowanalysis/dead_loop_elimination.py @@ -1,4 +1,5 @@ """Module implementing the DeadLoopElimination pipeline stage.""" + from logging import info, warning from typing import Dict, Generator, Optional, Tuple, Union diff --git a/decompiler/pipeline/dataflowanalysis/dead_path_elimination.py b/decompiler/pipeline/dataflowanalysis/dead_path_elimination.py index d7771877a..571c7a7ab 100644 --- a/decompiler/pipeline/dataflowanalysis/dead_path_elimination.py +++ b/decompiler/pipeline/dataflowanalysis/dead_path_elimination.py @@ -1,4 +1,5 @@ """Module implementing the DeadPathElimination pipeline stage.""" + from logging import info, warning from typing import Iterator, Optional, Set, Union diff --git a/decompiler/pipeline/dataflowanalysis/deadcodeelimination.py b/decompiler/pipeline/dataflowanalysis/deadcodeelimination.py index 75d820590..02ab0a589 100644 --- a/decompiler/pipeline/dataflowanalysis/deadcodeelimination.py +++ b/decompiler/pipeline/dataflowanalysis/deadcodeelimination.py @@ -1,4 +1,5 @@ """Module implementing code elimination based on Hols et al.""" + from collections import defaultdict, namedtuple from typing import DefaultDict, Optional, Set diff --git a/decompiler/pipeline/dataflowanalysis/identity_elimination.py b/decompiler/pipeline/dataflowanalysis/identity_elimination.py index 687835635..5a6827274 100644 --- a/decompiler/pipeline/dataflowanalysis/identity_elimination.py +++ b/decompiler/pipeline/dataflowanalysis/identity_elimination.py @@ -1,4 +1,5 @@ """Module implementing a pipeline stage eliminating congruent variables.""" + from __future__ import annotations from collections import defaultdict, namedtuple diff --git a/decompiler/pipeline/dataflowanalysis/type_propagation.py b/decompiler/pipeline/dataflowanalysis/type_propagation.py index 20213ea9c..d234cb01c 100644 --- a/decompiler/pipeline/dataflowanalysis/type_propagation.py +++ b/decompiler/pipeline/dataflowanalysis/type_propagation.py @@ -1,4 +1,5 @@ """Module implementing horizontal type propagation as a pipeline stage.""" + from __future__ import annotations from collections import Counter, defaultdict diff --git a/decompiler/pipeline/expressions/deadcomponentpruner.py b/decompiler/pipeline/expressions/deadcomponentpruner.py index a657d7c32..4714f6440 100644 --- a/decompiler/pipeline/expressions/deadcomponentpruner.py +++ b/decompiler/pipeline/expressions/deadcomponentpruner.py @@ -1,4 +1,5 @@ """Module implementing Dead code elimination based on ExpressionGraphs.""" + from typing import Iterator from decompiler.pipeline.stage import PipelineStage diff --git a/decompiler/pipeline/expressions/edgepruner.py b/decompiler/pipeline/expressions/edgepruner.py index d92ea646f..d7144419c 100644 --- a/decompiler/pipeline/expressions/edgepruner.py +++ b/decompiler/pipeline/expressions/edgepruner.py @@ -1,4 +1,5 @@ """Module implementing common subexpression elimination on ExpressionGraphs.""" + from typing import Iterator, List from decompiler.pipeline.stage import PipelineStage diff --git a/decompiler/pipeline/pipeline.py b/decompiler/pipeline/pipeline.py index 829efa2ce..74e4267a3 100644 --- a/decompiler/pipeline/pipeline.py +++ b/decompiler/pipeline/pipeline.py @@ -1,4 +1,5 @@ """Module containing pipeline definitions for the decompiler.""" + from __future__ import annotations from logging import debug, error, warning diff --git a/decompiler/pipeline/preprocessing/coherence.py b/decompiler/pipeline/preprocessing/coherence.py index 6095a1add..040e0c445 100644 --- a/decompiler/pipeline/preprocessing/coherence.py +++ b/decompiler/pipeline/preprocessing/coherence.py @@ -1,4 +1,5 @@ """Module implementing frontend data harmonization.""" + from itertools import chain from logging import info from typing import Dict, Iterator, List diff --git a/decompiler/pipeline/preprocessing/compiler_idiom_handling.py b/decompiler/pipeline/preprocessing/compiler_idiom_handling.py index 640e91d69..3f0074fd5 100644 --- a/decompiler/pipeline/preprocessing/compiler_idiom_handling.py +++ b/decompiler/pipeline/preprocessing/compiler_idiom_handling.py @@ -1,4 +1,5 @@ """Module for handling compiler idioms that have already been marked in BinaryNinja""" + import logging from dataclasses import dataclass from typing import Iterable, List, Optional diff --git a/decompiler/pipeline/preprocessing/missing_definitions.py b/decompiler/pipeline/preprocessing/missing_definitions.py index 64fa96cf9..e84cfacd5 100644 --- a/decompiler/pipeline/preprocessing/missing_definitions.py +++ b/decompiler/pipeline/preprocessing/missing_definitions.py @@ -1,4 +1,5 @@ """Module dedicated to insert definitions for otherwise definitionless values.""" + from collections import defaultdict from logging import error from typing import DefaultDict, Dict, List, Optional, Set, Tuple, Union diff --git a/decompiler/pipeline/preprocessing/phi_predecessors.py b/decompiler/pipeline/preprocessing/phi_predecessors.py index 4eb922bc9..b924efdc1 100644 --- a/decompiler/pipeline/preprocessing/phi_predecessors.py +++ b/decompiler/pipeline/preprocessing/phi_predecessors.py @@ -1,4 +1,5 @@ """Module fixing the Control Glow Graph such that it contains all information we need for our analysis.""" + from typing import Dict, List, Optional from decompiler.pipeline.stage import PipelineStage diff --git a/decompiler/pipeline/preprocessing/register_pair_handling.py b/decompiler/pipeline/preprocessing/register_pair_handling.py index 0525b2255..cad07d269 100644 --- a/decompiler/pipeline/preprocessing/register_pair_handling.py +++ b/decompiler/pipeline/preprocessing/register_pair_handling.py @@ -1,4 +1,5 @@ """Module to handle Register pairs.""" + from __future__ import annotations from collections import namedtuple diff --git a/decompiler/pipeline/preprocessing/remove_stack_canary.py b/decompiler/pipeline/preprocessing/remove_stack_canary.py index 0a37977f2..3bd000fe0 100644 --- a/decompiler/pipeline/preprocessing/remove_stack_canary.py +++ b/decompiler/pipeline/preprocessing/remove_stack_canary.py @@ -1,4 +1,5 @@ """Module for removing ELF stack canaries.""" + from typing import Iterator from decompiler.pipeline.stage import PipelineStage diff --git a/decompiler/pipeline/preprocessing/switch_variable_detection.py b/decompiler/pipeline/preprocessing/switch_variable_detection.py index c1ac78992..b24ecc222 100644 --- a/decompiler/pipeline/preprocessing/switch_variable_detection.py +++ b/decompiler/pipeline/preprocessing/switch_variable_detection.py @@ -1,4 +1,5 @@ """Module for finding variable relevant to switch""" + from typing import Optional from decompiler.pipeline.stage import PipelineStage diff --git a/decompiler/pipeline/preprocessing/util.py b/decompiler/pipeline/preprocessing/util.py index 381234eb8..ea7060c3c 100644 --- a/decompiler/pipeline/preprocessing/util.py +++ b/decompiler/pipeline/preprocessing/util.py @@ -1,4 +1,5 @@ """Helper functions for modules in the preprocessing pipeline.""" + from collections import defaultdict from typing import DefaultDict, Dict, Set, Tuple diff --git a/decompiler/pipeline/ssa/outofssatranslation.py b/decompiler/pipeline/ssa/outofssatranslation.py index 270461281..cd76fe4c5 100644 --- a/decompiler/pipeline/ssa/outofssatranslation.py +++ b/decompiler/pipeline/ssa/outofssatranslation.py @@ -1,4 +1,5 @@ """Module implementing Out of SSA.""" + import logging from collections import defaultdict from configparser import NoOptionError diff --git a/decompiler/pipeline/ssa/phi_cleaner.py b/decompiler/pipeline/ssa/phi_cleaner.py index 69a4a2233..58cea284e 100644 --- a/decompiler/pipeline/ssa/phi_cleaner.py +++ b/decompiler/pipeline/ssa/phi_cleaner.py @@ -1,4 +1,5 @@ """Module for removing unnecessary Phi-functions in Out of SSA.""" + from typing import Dict, Iterator, List from decompiler.pipeline.ssa.phi_dependency_graph import PhiDependencyGraph diff --git a/decompiler/pipeline/ssa/phi_dependency_resolver.py b/decompiler/pipeline/ssa/phi_dependency_resolver.py index 6bc2d5325..c57bbc928 100644 --- a/decompiler/pipeline/ssa/phi_dependency_resolver.py +++ b/decompiler/pipeline/ssa/phi_dependency_resolver.py @@ -1,4 +1,5 @@ """Module for removing circular dependency of Phi-functions in Out of SSA.""" + import logging from typing import Dict, List diff --git a/decompiler/pipeline/ssa/phi_lifting.py b/decompiler/pipeline/ssa/phi_lifting.py index 4ef0e521a..d001abfcc 100644 --- a/decompiler/pipeline/ssa/phi_lifting.py +++ b/decompiler/pipeline/ssa/phi_lifting.py @@ -1,4 +1,5 @@ """Module for removing Phi-functions by lifting in Out of SSA.""" + import logging from typing import DefaultDict, Iterator, List, Optional diff --git a/decompiler/pipeline/ssa/variable_renaming.py b/decompiler/pipeline/ssa/variable_renaming.py index fe361c6ce..910e0d6cf 100644 --- a/decompiler/pipeline/ssa/variable_renaming.py +++ b/decompiler/pipeline/ssa/variable_renaming.py @@ -1,4 +1,5 @@ """Module for renaming variables in Out of SSA.""" + import logging from collections import defaultdict from dataclasses import dataclass, field diff --git a/decompiler/pipeline/stage.py b/decompiler/pipeline/stage.py index 14058db5c..5cf3304d2 100644 --- a/decompiler/pipeline/stage.py +++ b/decompiler/pipeline/stage.py @@ -1,4 +1,5 @@ """Module implementing the PipelineStage interface.""" + from abc import ABC, abstractmethod from decompiler.task import DecompilerTask diff --git a/decompiler/structures/ast/reachability_graph.py b/decompiler/structures/ast/reachability_graph.py index 676228acf..379c83b61 100644 --- a/decompiler/structures/ast/reachability_graph.py +++ b/decompiler/structures/ast/reachability_graph.py @@ -1,4 +1,5 @@ """Module to handle the reaches attribute using graphs.""" + from __future__ import annotations from itertools import chain, permutations, product diff --git a/decompiler/structures/graphs/basic.py b/decompiler/structures/graphs/basic.py index 13ce99e2e..b1bfed9c9 100644 --- a/decompiler/structures/graphs/basic.py +++ b/decompiler/structures/graphs/basic.py @@ -1,4 +1,5 @@ """Module implementing basic nodes based on aa given (printable) python object.""" + from __future__ import annotations from typing import Any diff --git a/decompiler/structures/graphs/basicblock.py b/decompiler/structures/graphs/basicblock.py index 61e0d4324..44e5aef0c 100644 --- a/decompiler/structures/graphs/basicblock.py +++ b/decompiler/structures/graphs/basicblock.py @@ -1,4 +1,5 @@ """Module defining the BasicBlock class utilized in ControlFlowGraphs.""" + from __future__ import annotations from enum import Enum diff --git a/decompiler/structures/graphs/branches.py b/decompiler/structures/graphs/branches.py index 0aeeefe26..0d0c484e9 100644 --- a/decompiler/structures/graphs/branches.py +++ b/decompiler/structures/graphs/branches.py @@ -1,4 +1,5 @@ """Module defining the various branches between BasicBlocks used in ControlFlowGraphs.""" + from __future__ import annotations from abc import ABC, abstractmethod diff --git a/decompiler/structures/graphs/cfg.py b/decompiler/structures/graphs/cfg.py index 500558066..5b44110f6 100644 --- a/decompiler/structures/graphs/cfg.py +++ b/decompiler/structures/graphs/cfg.py @@ -1,4 +1,5 @@ """Module defining a control flow graph with the graph interface.""" + from __future__ import annotations from itertools import chain diff --git a/decompiler/structures/graphs/classifiedgraph.py b/decompiler/structures/graphs/classifiedgraph.py index 83202630a..80f29b9f2 100644 --- a/decompiler/structures/graphs/classifiedgraph.py +++ b/decompiler/structures/graphs/classifiedgraph.py @@ -1,4 +1,5 @@ """Module implementing edge classification for NetworkXGraph.""" + from __future__ import annotations from collections import defaultdict diff --git a/decompiler/structures/graphs/expressiongraph.py b/decompiler/structures/graphs/expressiongraph.py index 4f6e7344a..6aa04e323 100644 --- a/decompiler/structures/graphs/expressiongraph.py +++ b/decompiler/structures/graphs/expressiongraph.py @@ -1,4 +1,5 @@ """Module defining the ExpressionGraph used for various pipeline stages.""" + from __future__ import annotations from decompiler.structures.graphs.cfg import ControlFlowGraph diff --git a/decompiler/structures/graphs/interface/__init__.py b/decompiler/structures/graphs/interface/__init__.py index a03259776..f6cc49860 100644 --- a/decompiler/structures/graphs/interface/__init__.py +++ b/decompiler/structures/graphs/interface/__init__.py @@ -1,3 +1,4 @@ """Module defining the graph interface.""" + from .graph import EDGE, NODE, GraphEdgeInterface, GraphInterface, GraphNodeInterface from .rooted import RootedGraphInterface diff --git a/decompiler/structures/graphs/interface/edge.py b/decompiler/structures/graphs/interface/edge.py index 435ada805..2985aee18 100644 --- a/decompiler/structures/graphs/interface/edge.py +++ b/decompiler/structures/graphs/interface/edge.py @@ -1,4 +1,5 @@ """Module defining the edge interface linking node objects.""" + from __future__ import annotations from abc import ABC, abstractmethod diff --git a/decompiler/structures/graphs/interface/graph.py b/decompiler/structures/graphs/interface/graph.py index 7f6186b41..47a4d7a2b 100644 --- a/decompiler/structures/graphs/interface/graph.py +++ b/decompiler/structures/graphs/interface/graph.py @@ -1,4 +1,5 @@ """Defines a generic graph interface suitable for multiple graph backends.""" + from __future__ import annotations from abc import ABC, abstractmethod diff --git a/decompiler/structures/graphs/interface/node.py b/decompiler/structures/graphs/interface/node.py index 79b1d8283..ba0c9cc06 100644 --- a/decompiler/structures/graphs/interface/node.py +++ b/decompiler/structures/graphs/interface/node.py @@ -1,4 +1,5 @@ """Module defining the most basic node interface.""" + from __future__ import annotations from abc import ABC, abstractmethod diff --git a/decompiler/structures/graphs/interface/rooted.py b/decompiler/structures/graphs/interface/rooted.py index bea172eb5..992efd27f 100644 --- a/decompiler/structures/graphs/interface/rooted.py +++ b/decompiler/structures/graphs/interface/rooted.py @@ -1,4 +1,5 @@ """Module defining the interface for rooted graphs.""" + from abc import ABC, abstractmethod from typing import Optional diff --git a/decompiler/structures/graphs/nxgraph.py b/decompiler/structures/graphs/nxgraph.py index d2ae4643a..e8ca6f9fd 100644 --- a/decompiler/structures/graphs/nxgraph.py +++ b/decompiler/structures/graphs/nxgraph.py @@ -1,4 +1,5 @@ """Module implementing networkx as a graph backend.""" + from __future__ import annotations from typing import Dict, Iterator, Optional, Tuple, TypeVar diff --git a/decompiler/structures/graphs/rootedgraph.py b/decompiler/structures/graphs/rootedgraph.py index 4768a0bc2..9b5249273 100644 --- a/decompiler/structures/graphs/rootedgraph.py +++ b/decompiler/structures/graphs/rootedgraph.py @@ -1,4 +1,5 @@ """Module implementing a rooted graph with buffered dominator tree.""" + from __future__ import annotations from typing import Iterable, Optional, Tuple diff --git a/decompiler/structures/interferencegraph.py b/decompiler/structures/interferencegraph.py index 9beb72545..9507a854a 100644 --- a/decompiler/structures/interferencegraph.py +++ b/decompiler/structures/interferencegraph.py @@ -1,4 +1,5 @@ """Class for the Interference Graph""" + from __future__ import annotations from itertools import combinations diff --git a/decompiler/structures/pseudo/delogic_logic.py b/decompiler/structures/pseudo/delogic_logic.py index e097206c1..fdb19d013 100644 --- a/decompiler/structures/pseudo/delogic_logic.py +++ b/decompiler/structures/pseudo/delogic_logic.py @@ -1,4 +1,5 @@ """Implements translating pseudo instructions into delogic statements.""" + from __future__ import annotations from typing import Union diff --git a/decompiler/structures/pseudo/expressions.py b/decompiler/structures/pseudo/expressions.py index 907410466..0458ee34f 100644 --- a/decompiler/structures/pseudo/expressions.py +++ b/decompiler/structures/pseudo/expressions.py @@ -26,6 +26,7 @@ constant <- string_constant | numeric_constant """ + from __future__ import annotations from abc import ABC, abstractmethod diff --git a/decompiler/structures/pseudo/instructions.py b/decompiler/structures/pseudo/instructions.py index e0fca3687..75625e392 100644 --- a/decompiler/structures/pseudo/instructions.py +++ b/decompiler/structures/pseudo/instructions.py @@ -1,4 +1,5 @@ """Module modeling all pseudo code instructions.""" + from __future__ import annotations import logging diff --git a/decompiler/structures/pseudo/logic.py b/decompiler/structures/pseudo/logic.py index b233658ed..d8f34d292 100644 --- a/decompiler/structures/pseudo/logic.py +++ b/decompiler/structures/pseudo/logic.py @@ -1,4 +1,5 @@ """Implements translating psuedo instructions into logic statements.""" + from __future__ import annotations from abc import ABC, abstractmethod diff --git a/decompiler/structures/pseudo/operations.py b/decompiler/structures/pseudo/operations.py index 95045067c..3c05d6f95 100644 --- a/decompiler/structures/pseudo/operations.py +++ b/decompiler/structures/pseudo/operations.py @@ -1,4 +1,5 @@ """Module declaring all valid IR operations.""" + from __future__ import annotations import logging diff --git a/decompiler/structures/pseudo/typing.py b/decompiler/structures/pseudo/typing.py index d679023c9..f27086bcc 100644 --- a/decompiler/structures/pseudo/typing.py +++ b/decompiler/structures/pseudo/typing.py @@ -1,4 +1,5 @@ """Module implementing the typing system for the pseudo language.""" + from __future__ import annotations from abc import ABC, abstractmethod diff --git a/decompiler/structures/pseudo/z3_logic.py b/decompiler/structures/pseudo/z3_logic.py index 8b4108ac8..bc6a8344e 100644 --- a/decompiler/structures/pseudo/z3_logic.py +++ b/decompiler/structures/pseudo/z3_logic.py @@ -1,4 +1,5 @@ """Implements translating psuedo instructions into logic statements.""" + from __future__ import annotations import logging diff --git a/decompiler/structures/visitors/interfaces.py b/decompiler/structures/visitors/interfaces.py index 9269cec11..dea82fe2f 100644 --- a/decompiler/structures/visitors/interfaces.py +++ b/decompiler/structures/visitors/interfaces.py @@ -1,4 +1,5 @@ """Module for visitor ABCs.""" + from abc import ABC, abstractmethod from typing import Generic, TypeVar diff --git a/decompiler/task.py b/decompiler/task.py index f46a28777..66a725db4 100644 --- a/decompiler/task.py +++ b/decompiler/task.py @@ -1,4 +1,5 @@ """Module describing tasks to be handled by the decompiler pipleline.""" + from typing import Dict, List, Optional from decompiler.structures.ast.syntaxtree import AbstractSyntaxTree diff --git a/decompiler/util/commandline.py b/decompiler/util/commandline.py index dee775065..56449281d 100644 --- a/decompiler/util/commandline.py +++ b/decompiler/util/commandline.py @@ -1,4 +1,5 @@ """Command line interface for the decompiler.""" + from argparse import SUPPRESS, ArgumentParser from enum import Enum from os import isatty diff --git a/decompiler/util/decoration.py b/decompiler/util/decoration.py index 92faf5354..7c29b12e1 100644 --- a/decompiler/util/decoration.py +++ b/decompiler/util/decoration.py @@ -1,4 +1,5 @@ """Module handling plotting and pretty printing.""" + from __future__ import annotations import textwrap diff --git a/decompiler/util/options.py b/decompiler/util/options.py index 51782c480..3b5be5c5c 100644 --- a/decompiler/util/options.py +++ b/decompiler/util/options.py @@ -1,4 +1,5 @@ """File in charge of managing config and commandline options for decompilation.""" + import json import logging from argparse import ArgumentParser, BooleanOptionalAction, Namespace diff --git a/decompiler/util/serialization/astnode_serializer.py b/decompiler/util/serialization/astnode_serializer.py index 425297063..1fde40393 100644 --- a/decompiler/util/serialization/astnode_serializer.py +++ b/decompiler/util/serialization/astnode_serializer.py @@ -1,4 +1,5 @@ """Module implementing the serialization of AbstractSyntaxTreeNode subclasses.""" + from abc import ABC from typing import Dict, Optional diff --git a/decompiler/util/serialization/interface.py b/decompiler/util/serialization/interface.py index ac4a1f521..d3fc02ade 100644 --- a/decompiler/util/serialization/interface.py +++ b/decompiler/util/serialization/interface.py @@ -1,4 +1,5 @@ """Module implementing the base interface for all serializers.""" + from abc import ABC, abstractmethod from typing import Dict, Generic, TypeVar diff --git a/test_threadsafety.py b/test_threadsafety.py index b8fb2b534..5c5673831 100644 --- a/test_threadsafety.py +++ b/test_threadsafety.py @@ -1,4 +1,5 @@ """Module testing whether dewolf is still threadsafe and z3 does not generate segmentationfaults anymore.""" + import faulthandler from concurrent.futures import ThreadPoolExecutor diff --git a/tests/pipeline/SSA/test_out_of_ssa.py b/tests/pipeline/SSA/test_out_of_ssa.py index 3604a80d1..eef639cab 100644 --- a/tests/pipeline/SSA/test_out_of_ssa.py +++ b/tests/pipeline/SSA/test_out_of_ssa.py @@ -1,4 +1,5 @@ """Pytest for Out of SSA.""" + from decompiler.pipeline.ssa.outofssatranslation import OutOfSsaTranslation from decompiler.structures.graphs.cfg import BasicBlockEdgeCondition from decompiler.structures.pseudo import Expression, Type, UnknownExpression diff --git a/tests/pipeline/SSA/test_phi_dependency_graph.py b/tests/pipeline/SSA/test_phi_dependency_graph.py index 9bf8ded58..e4fdbcb72 100644 --- a/tests/pipeline/SSA/test_phi_dependency_graph.py +++ b/tests/pipeline/SSA/test_phi_dependency_graph.py @@ -1,4 +1,5 @@ """Pytest for Dependency Graph in Out of SSA.""" + from typing import List import pytest diff --git a/tests/pipeline/commons/test_liveness_analysis.py b/tests/pipeline/commons/test_liveness_analysis.py index 605f8689b..973f23ad8 100644 --- a/tests/pipeline/commons/test_liveness_analysis.py +++ b/tests/pipeline/commons/test_liveness_analysis.py @@ -1,4 +1,5 @@ """Pytest for Liveness Analysis.""" + from typing import List, Tuple import pytest diff --git a/tests/pipeline/controlflowanalysis/restructuring_commons/test_condition_aware_refinement.py b/tests/pipeline/controlflowanalysis/restructuring_commons/test_condition_aware_refinement.py index 5a6e30cac..4dc0c105a 100644 --- a/tests/pipeline/controlflowanalysis/restructuring_commons/test_condition_aware_refinement.py +++ b/tests/pipeline/controlflowanalysis/restructuring_commons/test_condition_aware_refinement.py @@ -1,4 +1,5 @@ """ Tests for the PatternIndependentRestructuring pipeline stage condition aware refinement.""" + from itertools import combinations from typing import List, Tuple, Union diff --git a/tests/pipeline/dataflowanalysis/test_dead-code-elimination.py b/tests/pipeline/dataflowanalysis/test_dead-code-elimination.py index d5306c91f..a10e05831 100644 --- a/tests/pipeline/dataflowanalysis/test_dead-code-elimination.py +++ b/tests/pipeline/dataflowanalysis/test_dead-code-elimination.py @@ -1,4 +1,5 @@ """ Tests for the DeadCodeElimination pipeline stage""" + from abc import ABC, abstractmethod import pytest diff --git a/tests/pipeline/preprocessing/test-coherence.py b/tests/pipeline/preprocessing/test-coherence.py index 066d1cf11..85f7a3913 100644 --- a/tests/pipeline/preprocessing/test-coherence.py +++ b/tests/pipeline/preprocessing/test-coherence.py @@ -1,4 +1,5 @@ """Pytest for InsertingMissingDefinitions.""" + from typing import Dict import pytest diff --git a/tests/pipeline/preprocessing/test_insert_missing_definition.py b/tests/pipeline/preprocessing/test_insert_missing_definition.py index 6fcdcac02..75452c7c3 100644 --- a/tests/pipeline/preprocessing/test_insert_missing_definition.py +++ b/tests/pipeline/preprocessing/test_insert_missing_definition.py @@ -1,4 +1,5 @@ """Pytest for InsertingMissingDefinitions.""" + from typing import List import pytest diff --git a/tests/pipeline/test-pipeline.py b/tests/pipeline/test-pipeline.py index 48b709b70..cfb6023a8 100644 --- a/tests/pipeline/test-pipeline.py +++ b/tests/pipeline/test-pipeline.py @@ -1,4 +1,5 @@ """Tests for the pipeline system.""" + import pytest from decompiler.pipeline.default import AST_STAGES, CFG_STAGES from decompiler.pipeline.pipeline import DecompilerPipeline diff --git a/tests/structures/ast/test_syntaxforest.py b/tests/structures/ast/test_syntaxforest.py index 2d7ca423b..47529bc78 100644 --- a/tests/structures/ast/test_syntaxforest.py +++ b/tests/structures/ast/test_syntaxforest.py @@ -1,4 +1,5 @@ """ Tests for the AbstractSyntaxTree base class.""" + from itertools import combinations from decompiler.structures.ast.ast_comparator import ASTComparator diff --git a/tests/structures/ast/test_syntaxgraph.py b/tests/structures/ast/test_syntaxgraph.py index 720f834fa..48647c06f 100644 --- a/tests/structures/ast/test_syntaxgraph.py +++ b/tests/structures/ast/test_syntaxgraph.py @@ -1,4 +1,5 @@ """ Tests for the AbstractSyntaxTree base class.""" + from itertools import combinations from decompiler.structures.ast.syntaxforest import AbstractSyntaxInterface diff --git a/tests/structures/ast/test_syntaxtree.py b/tests/structures/ast/test_syntaxtree.py index 2a37ec925..853f25ea6 100644 --- a/tests/structures/ast/test_syntaxtree.py +++ b/tests/structures/ast/test_syntaxtree.py @@ -1,4 +1,5 @@ """ Tests for the AbstractSyntaxTree base class.""" + import pytest from decompiler.structures.ast.ast_nodes import CodeNode, SeqNode, VirtualRootNode from decompiler.structures.ast.syntaxtree import AbstractSyntaxTree diff --git a/tests/structures/graphs/test_basic.py b/tests/structures/graphs/test_basic.py index 165014d72..6f2c2920c 100644 --- a/tests/structures/graphs/test_basic.py +++ b/tests/structures/graphs/test_basic.py @@ -1,4 +1,5 @@ """Module implementing tests for the most basic node and edge implementations.""" + from decompiler.structures.graphs.basic import BasicEdge, BasicNode diff --git a/tests/structures/graphs/test_basicblock.py b/tests/structures/graphs/test_basicblock.py index 9a5a31d64..e278c521e 100644 --- a/tests/structures/graphs/test_basicblock.py +++ b/tests/structures/graphs/test_basicblock.py @@ -1,4 +1,5 @@ """Module implementing tests for the BasicBlock class pseudo instruction container.""" + from functools import partial import pytest diff --git a/tests/structures/graphs/test_classifiedgraph.py b/tests/structures/graphs/test_classifiedgraph.py index a4b4b6599..a46867e84 100644 --- a/tests/structures/graphs/test_classifiedgraph.py +++ b/tests/structures/graphs/test_classifiedgraph.py @@ -1,4 +1,5 @@ """Module implementing tests for the ClassifiedGraph class.""" + from decompiler.structures.graphs.basic import BasicEdge, BasicNode from decompiler.structures.graphs.classifiedgraph import ClassifiedGraph, EdgeProperty diff --git a/tests/structures/graphs/test_graph_interface.py b/tests/structures/graphs/test_graph_interface.py index b35187a3b..7b9b90868 100644 --- a/tests/structures/graphs/test_graph_interface.py +++ b/tests/structures/graphs/test_graph_interface.py @@ -1,4 +1,5 @@ """Implementing tests for the GraphInterface.""" + from typing import List, Tuple import pytest diff --git a/tests/structures/graphs/test_rootedgraph.py b/tests/structures/graphs/test_rootedgraph.py index 9b9568af9..a1bacdfe7 100644 --- a/tests/structures/graphs/test_rootedgraph.py +++ b/tests/structures/graphs/test_rootedgraph.py @@ -1,4 +1,5 @@ """Module implementing tests for the RootedGraph implementation.""" + from typing import Tuple from decompiler.structures.graphs.basic import BasicEdge, BasicNode diff --git a/tests/structures/logic/test_interface_decorator.py b/tests/structures/logic/test_interface_decorator.py index 408bcae5b..c6b161e44 100644 --- a/tests/structures/logic/test_interface_decorator.py +++ b/tests/structures/logic/test_interface_decorator.py @@ -26,8 +26,7 @@ def to_cnf(self): def test_classes_without_methods_can_be_wrapped(): - class TestCase(StupidBaseCase): - ... + class TestCase(StupidBaseCase): ... a = TestCase() assert a @@ -43,8 +42,7 @@ def __init__(self, inp): def test_classes_with_return_value(): - class TestCase(BaseCase): - ... + class TestCase(BaseCase): ... a = TestCase(5) assert a._input == 12 diff --git a/tests/structures/pseudo/test_typing.py b/tests/structures/pseudo/test_typing.py index 61eaef274..29222ff5b 100644 --- a/tests/structures/pseudo/test_typing.py +++ b/tests/structures/pseudo/test_typing.py @@ -1,4 +1,5 @@ """Tests for the pseudo typing functionality.""" + import pytest from decompiler.structures.pseudo.typing import CustomType, Float, Integer, Pointer, TypeParser diff --git a/tests/structures/test_interferencegraph.py b/tests/structures/test_interferencegraph.py index 402af1e6a..78692921d 100644 --- a/tests/structures/test_interferencegraph.py +++ b/tests/structures/test_interferencegraph.py @@ -1,4 +1,5 @@ """Pytest for the Interference Graph.""" + from typing import List, Tuple import pytest diff --git a/tests/util/test_lexicographical_bfs.py b/tests/util/test_lexicographical_bfs.py index 3c120d0c1..d881c9acd 100644 --- a/tests/util/test_lexicographical_bfs.py +++ b/tests/util/test_lexicographical_bfs.py @@ -1,4 +1,5 @@ """Pytest for lexicographical BFS.""" + from decompiler.structures.interferencegraph import InterferenceGraph from decompiler.util.lexicographical_bfs import LexicographicalBFS