Skip to content

Commit

Permalink
Enable+apply isort via ruff/pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dbast committed Aug 17, 2024
1 parent 1384ef5 commit facc907
Show file tree
Hide file tree
Showing 184 changed files with 749 additions and 701 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ repos:
hooks:
- id: check-toml
- id: check-yaml
- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.6
hooks:
- id: ruff
args: [--fix, --show-fixes]
- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.8.0-1
hooks:
Expand Down
9 changes: 5 additions & 4 deletions mypy-stubs/z3/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
from typing import (
overload,
Tuple,
Any,
List,
Iterable,
Iterator,
List,
Optional,
Sequence,
Tuple,
TypeVar,
Union,
Sequence,
overload,
)

from .z3types import Ast, ContextObj

class Context: ...
Expand Down
2 changes: 1 addition & 1 deletion myth
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
http://www.github.com/ConsenSys/mythril
"""
from sys import exit
import mythril.interfaces.cli

import mythril.interfaces.cli

if __name__ == "__main__":
mythril.interfaces.cli.main()
Expand Down
3 changes: 2 additions & 1 deletion mythril/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
__docformat__ = "restructuredtext"
import logging

from mythril.plugin.loader import MythrilPluginLoader

# Accept mythril.VERSION to get mythril's current version number
from .__version__ import __version__ as VERSION
from mythril.plugin.loader import MythrilPluginLoader

log = logging.getLogger(__name__)
4 changes: 2 additions & 2 deletions mythril/analysis/call_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

from typing import Union

from mythril.analysis.ops import VarType, Call, get_variable
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.analysis.ops import Call, VarType, get_variable
from mythril.laser.ethereum.natives import PRECOMPILE_COUNT
from mythril.laser.ethereum.state.global_state import GlobalState


def get_call_from_state(state: GlobalState) -> Union[Call, None]:
Expand Down
2 changes: 1 addition & 1 deletion mythril/analysis/issue_annotation.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from copy import deepcopy
from typing import List

from mythril.analysis.report import Issue
from mythril.laser.ethereum.state.annotation import StateAnnotation
from mythril.laser.smt import SMTBool as Bool
from copy import deepcopy


class IssueAnnotation(StateAnnotation):
Expand Down
2 changes: 1 addition & 1 deletion mythril/analysis/module/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from mythril.analysis.module.base import EntryPoint, DetectionModule
from mythril.analysis.module.base import DetectionModule, EntryPoint
from mythril.analysis.module.loader import ModuleLoader
from mythril.analysis.module.util import (
get_detection_module_hooks,
Expand Down
6 changes: 3 additions & 3 deletions mythril/analysis/module/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"""

import logging
from typing import List, Set, Optional, Tuple
from abc import ABC, abstractmethod
from enum import Enum
from typing import List, Optional, Set, Tuple

from mythril.analysis.report import Issue
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.support.support_args import args
from mythril.support.support_utils import get_code_hash
from abc import ABC, abstractmethod
from enum import Enum

# Get logger instance
log = logging.getLogger(__name__)
Expand Down
15 changes: 6 additions & 9 deletions mythril/analysis/module/loader.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from mythril.analysis.module.base import DetectionModule, EntryPoint
from mythril.support.support_utils import Singleton
from mythril.support.support_args import args
from typing import List, Optional

from mythril.analysis.module.base import DetectionModule, EntryPoint
from mythril.analysis.module.modules.arbitrary_jump import ArbitraryJump
from mythril.analysis.module.modules.arbitrary_write import ArbitraryStorage
from mythril.analysis.module.modules.delegatecall import ArbitraryDelegateCall
from mythril.analysis.module.modules.dependence_on_origin import TxOrigin
from mythril.analysis.module.modules.dependence_on_predictable_vars import (
PredictableVariables,
)
from mythril.analysis.module.modules.dependence_on_origin import TxOrigin
from mythril.analysis.module.modules.ether_thief import EtherThief
from mythril.analysis.module.modules.exceptions import Exceptions
from mythril.analysis.module.modules.external_calls import ExternalCalls
Expand All @@ -23,13 +22,11 @@
TransactionOrderDependence,
)
from mythril.analysis.module.modules.unchecked_retval import UncheckedRetval
from mythril.analysis.module.modules.user_assertions import UserAssertions
from mythril.analysis.module.modules.unexpected_ether import UnexpectedEther


from mythril.analysis.module.modules.user_assertions import UserAssertions
from mythril.exceptions import DetectorNotFoundError

from typing import Optional, List
from mythril.support.support_args import args
from mythril.support.support_utils import Singleton


class ModuleLoader(object, metaclass=Singleton):
Expand Down
5 changes: 2 additions & 3 deletions mythril/analysis/module/modules/arbitrary_jump.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

import logging

from mythril.analysis.solver import get_transaction_sequence, UnsatError
from mythril.analysis.issue_annotation import IssueAnnotation
from mythril.analysis.module.base import DetectionModule, Issue, EntryPoint
from mythril.analysis.module.base import DetectionModule, EntryPoint, Issue
from mythril.analysis.solver import UnsatError, get_transaction_sequence
from mythril.analysis.swc_data import ARBITRARY_JUMP

from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.laser.smt import And, BitVec, symbol_factory
from mythril.support.model import get_model
Expand Down
4 changes: 2 additions & 2 deletions mythril/analysis/module/modules/arbitrary_write.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""This module contains the detection code for arbitrary storage write."""

import logging

from mythril.analysis.module.base import DetectionModule, EntryPoint
from mythril.analysis.potential_issues import (
get_potential_issues_annotation,
PotentialIssue,
get_potential_issues_annotation,
)

from mythril.analysis.swc_data import WRITE_TO_ARBITRARY_STORAGE
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.laser.smt import symbol_factory
Expand Down
10 changes: 5 additions & 5 deletions mythril/analysis/module/modules/delegatecall.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
import logging
from typing import List

from mythril.analysis.module.base import DetectionModule, EntryPoint
from mythril.analysis.potential_issues import (
get_potential_issues_annotation,
PotentialIssue,
get_potential_issues_annotation,
)
from mythril.analysis.swc_data import DELEGATECALL_TO_UNTRUSTED_CONTRACT
from mythril.exceptions import UnsatError
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.laser.ethereum.transaction.symbolic import ACTORS
from mythril.laser.ethereum.transaction.transaction_models import (
ContractCreationTransaction,
)
from mythril.analysis.module.base import DetectionModule, EntryPoint
from mythril.exceptions import UnsatError
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.laser.smt import symbol_factory, UGT
from mythril.laser.smt import UGT, symbol_factory

log = logging.getLogger(__name__)

Expand Down
7 changes: 4 additions & 3 deletions mythril/analysis/module/modules/dependence_on_origin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@

import logging
from copy import copy
from typing import List

from mythril.analysis import solver
from mythril.analysis.issue_annotation import IssueAnnotation
from mythril.analysis.module.base import DetectionModule, EntryPoint
from mythril.analysis.report import Issue
from mythril.exceptions import UnsatError
from mythril.analysis import solver
from mythril.analysis.swc_data import TX_ORIGIN_USAGE
from mythril.exceptions import UnsatError
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.laser.smt import And
from typing import List

log = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
dependence."""

import logging
from typing import List, cast

from mythril.analysis import solver
from mythril.analysis.issue_annotation import IssueAnnotation
from mythril.analysis.module.base import DetectionModule, EntryPoint
from mythril.analysis.module.module_helpers import is_prehook
from mythril.analysis.report import Issue
from mythril.exceptions import UnsatError
from mythril.analysis import solver
from mythril.laser.smt import And, ULT, symbol_factory
from mythril.analysis.swc_data import TIMESTAMP_DEPENDENCE, WEAK_RANDOMNESS
from mythril.analysis.module.module_helpers import is_prehook
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.exceptions import UnsatError
from mythril.laser.ethereum.state.annotation import StateAnnotation
from typing import cast, List
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.laser.smt import ULT, And, symbol_factory

log = logging.getLogger(__name__)

Expand Down
8 changes: 4 additions & 4 deletions mythril/analysis/module/modules/ether_thief.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
import logging
from copy import copy

from mythril.analysis import solver
from mythril.analysis.module.base import DetectionModule, EntryPoint
from mythril.analysis.potential_issues import (
get_potential_issues_annotation,
PotentialIssue,
get_potential_issues_annotation,
)
from mythril.laser.ethereum.transaction.symbolic import ACTORS
from mythril.analysis.swc_data import UNPROTECTED_ETHER_WITHDRAWAL
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.analysis import solver
from mythril.exceptions import UnsatError
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.laser.ethereum.transaction.symbolic import ACTORS
from mythril.laser.smt import UGT

log = logging.getLogger(__name__)
Expand Down
8 changes: 3 additions & 5 deletions mythril/analysis/module/modules/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
"""This module contains the detection code for reachable exceptions."""

import logging
from typing import List, Optional, cast

from typing import cast, List, Optional
from mythril.analysis import solver
from mythril.analysis.issue_annotation import IssueAnnotation
from mythril.analysis.module.base import DetectionModule, EntryPoint
from mythril.analysis.report import Issue
from mythril.analysis.swc_data import ASSERT_VIOLATION
from mythril.exceptions import UnsatError

from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.laser.ethereum.state.annotation import StateAnnotation
from mythril.laser.ethereum import util
from mythril.laser.ethereum.state.annotation import StateAnnotation
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.laser.smt import And

from mythril.support.support_utils import get_code_hash

log = logging.getLogger(__name__)
Expand Down
15 changes: 8 additions & 7 deletions mythril/analysis/module/modules/external_calls.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
"""This module contains the detection code for potentially insecure low-level
calls."""

import logging
from copy import copy

from mythril.analysis import solver
from mythril.analysis.module.base import DetectionModule, EntryPoint
from mythril.analysis.potential_issues import (
PotentialIssue,
get_potential_issues_annotation,
)
from mythril.analysis.swc_data import REENTRANCY
from mythril.laser.ethereum.state.constraints import Constraints
from mythril.laser.ethereum.transaction.symbolic import ACTORS
from mythril.analysis.module.base import DetectionModule, EntryPoint
from mythril.laser.smt import UGT, symbol_factory, Or, BitVec
from mythril.exceptions import UnsatError
from mythril.laser.ethereum.natives import PRECOMPILE_COUNT
from mythril.laser.ethereum.state.constraints import Constraints
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.exceptions import UnsatError
from copy import copy
import logging
from mythril.laser.ethereum.transaction.symbolic import ACTORS
from mythril.laser.smt import UGT, BitVec, Or, symbol_factory

log = logging.getLogger(__name__)

Expand Down
27 changes: 14 additions & 13 deletions mythril/analysis/module/modules/integer.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
"""This module contains the detection code for integer overflows and
underflows."""

from math import log2, ceil
from typing import cast, List, Set
import logging
from copy import copy
from math import ceil, log2
from typing import List, Set, cast

from mythril.analysis import solver
from mythril.analysis.issue_annotation import IssueAnnotation
from mythril.analysis.module.base import DetectionModule, EntryPoint
from mythril.analysis.report import Issue
from mythril.analysis.swc_data import INTEGER_OVERFLOW_AND_UNDERFLOW
from mythril.exceptions import UnsatError
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.laser.ethereum.state.annotation import StateAnnotation
from mythril.analysis.module.base import DetectionModule, EntryPoint
from copy import copy

from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.laser.smt import (
And,
BitVec,
BVAddNoOverflow,
BVSubNoUnderflow,
BVMulNoOverflow,
BitVec,
BVSubNoUnderflow,
Expression,
If,
symbol_factory,
Not,
Expression,
symbol_factory,
)
from mythril.laser.smt import (
SMTBool as Bool,
And,
)

import logging

log = logging.getLogger(__name__)


Expand Down
9 changes: 5 additions & 4 deletions mythril/analysis/module/modules/multiple_sends.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
"""This module contains the detection code to find multiple sends occurring in
a single transaction."""

import logging
from copy import copy
from typing import cast, List
from typing import List, cast

from mythril.analysis.issue_annotation import IssueAnnotation
from mythril.analysis.module.base import DetectionModule, EntryPoint
from mythril.analysis.report import Issue
from mythril.analysis.solver import get_transaction_sequence, UnsatError
from mythril.analysis.solver import UnsatError, get_transaction_sequence
from mythril.analysis.swc_data import MULTIPLE_SENDS
from mythril.analysis.module.base import DetectionModule, EntryPoint
from mythril.laser.ethereum.state.annotation import StateAnnotation
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.laser.smt import And
import logging

log = logging.getLogger(__name__)

Expand Down
Loading

0 comments on commit facc907

Please sign in to comment.