Skip to content

Commit 0717111

Browse files
dbastnorhh
andauthored
Enable+apply isort via ruff/pre-commit (#1871)
* Enable+apply isort via ruff/pre-commit * Fix cyclic imports --------- Co-authored-by: Nikhil Parasaram <[email protected]>
1 parent 9bbe7d6 commit 0717111

File tree

184 files changed

+749
-701
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+749
-701
lines changed

.pre-commit-config.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ repos:
1010
hooks:
1111
- id: check-toml
1212
- id: check-yaml
13-
- repo: https://github.com/psf/black
14-
rev: 24.8.0
15-
hooks:
16-
- id: black
1713
- repo: https://github.com/astral-sh/ruff-pre-commit
1814
rev: v0.6.1
1915
hooks:
2016
- id: ruff
2117
args: [--fix, --show-fixes]
18+
- repo: https://github.com/psf/black
19+
rev: 24.8.0
20+
hooks:
21+
- id: black
2222
- repo: https://github.com/scop/pre-commit-shfmt
2323
rev: v3.8.0-1
2424
hooks:

mypy-stubs/z3/__init__.pyi

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
from typing import (
2-
overload,
3-
Tuple,
42
Any,
5-
List,
63
Iterable,
74
Iterator,
5+
List,
86
Optional,
7+
Sequence,
8+
Tuple,
99
TypeVar,
1010
Union,
11-
Sequence,
11+
overload,
1212
)
13+
1314
from .z3types import Ast, ContextObj
1415

1516
class Context: ...

myth

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
http://www.github.com/ConsenSys/mythril
55
"""
66
from sys import exit
7-
import mythril.interfaces.cli
87

8+
import mythril.interfaces.cli
99

1010
if __name__ == "__main__":
1111
mythril.interfaces.cli.main()

mythril/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
__docformat__ = "restructuredtext"
44
import logging
55

6+
from mythril.plugin.loader import MythrilPluginLoader
7+
68
# Accept mythril.VERSION to get mythril's current version number
79
from .__version__ import __version__ as VERSION
8-
from mythril.plugin.loader import MythrilPluginLoader
910

1011
log = logging.getLogger(__name__)

mythril/analysis/call_helpers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
from typing import Union
55

6-
from mythril.analysis.ops import VarType, Call, get_variable
7-
from mythril.laser.ethereum.state.global_state import GlobalState
6+
from mythril.analysis.ops import Call, VarType, get_variable
87
from mythril.laser.ethereum.natives import PRECOMPILE_COUNT
8+
from mythril.laser.ethereum.state.global_state import GlobalState
99

1010

1111
def get_call_from_state(state: GlobalState) -> Union[Call, None]:

mythril/analysis/issue_annotation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
from copy import deepcopy
12
from typing import List
23

34
from mythril.analysis.report import Issue
45
from mythril.laser.ethereum.state.annotation import StateAnnotation
56
from mythril.laser.smt import SMTBool as Bool
6-
from copy import deepcopy
77

88

99
class IssueAnnotation(StateAnnotation):

mythril/analysis/module/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from mythril.analysis.module.base import EntryPoint, DetectionModule
1+
from mythril.analysis.module.base import DetectionModule, EntryPoint
22
from mythril.analysis.module.loader import ModuleLoader
33
from mythril.analysis.module.util import (
44
get_detection_module_hooks,

mythril/analysis/module/base.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
"""
66

77
import logging
8-
from typing import List, Set, Optional, Tuple
8+
from abc import ABC, abstractmethod
9+
from enum import Enum
10+
from typing import List, Optional, Set, Tuple
911

1012
from mythril.analysis.report import Issue
1113
from mythril.laser.ethereum.state.global_state import GlobalState
1214
from mythril.support.support_args import args
1315
from mythril.support.support_utils import get_code_hash
14-
from abc import ABC, abstractmethod
15-
from enum import Enum
1616

1717
# Get logger instance
1818
log = logging.getLogger(__name__)

mythril/analysis/module/loader.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
from mythril.analysis.module.base import DetectionModule, EntryPoint
2-
from mythril.support.support_utils import Singleton
3-
from mythril.support.support_args import args
1+
from typing import List, Optional
42

3+
from mythril.analysis.module.base import DetectionModule, EntryPoint
54
from mythril.analysis.module.modules.arbitrary_jump import ArbitraryJump
65
from mythril.analysis.module.modules.arbitrary_write import ArbitraryStorage
76
from mythril.analysis.module.modules.delegatecall import ArbitraryDelegateCall
7+
from mythril.analysis.module.modules.dependence_on_origin import TxOrigin
88
from mythril.analysis.module.modules.dependence_on_predictable_vars import (
99
PredictableVariables,
1010
)
11-
from mythril.analysis.module.modules.dependence_on_origin import TxOrigin
1211
from mythril.analysis.module.modules.ether_thief import EtherThief
1312
from mythril.analysis.module.modules.exceptions import Exceptions
1413
from mythril.analysis.module.modules.external_calls import ExternalCalls
@@ -23,13 +22,11 @@
2322
TransactionOrderDependence,
2423
)
2524
from mythril.analysis.module.modules.unchecked_retval import UncheckedRetval
26-
from mythril.analysis.module.modules.user_assertions import UserAssertions
2725
from mythril.analysis.module.modules.unexpected_ether import UnexpectedEther
28-
29-
26+
from mythril.analysis.module.modules.user_assertions import UserAssertions
3027
from mythril.exceptions import DetectorNotFoundError
31-
32-
from typing import Optional, List
28+
from mythril.support.support_args import args
29+
from mythril.support.support_utils import Singleton
3330

3431

3532
class ModuleLoader(object, metaclass=Singleton):

mythril/analysis/module/modules/arbitrary_jump.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
import logging
44

5-
from mythril.analysis.solver import get_transaction_sequence, UnsatError
65
from mythril.analysis.issue_annotation import IssueAnnotation
7-
from mythril.analysis.module.base import DetectionModule, Issue, EntryPoint
6+
from mythril.analysis.module.base import DetectionModule, EntryPoint, Issue
7+
from mythril.analysis.solver import UnsatError, get_transaction_sequence
88
from mythril.analysis.swc_data import ARBITRARY_JUMP
9-
109
from mythril.laser.ethereum.state.global_state import GlobalState
1110
from mythril.laser.smt import And, BitVec, symbol_factory
1211
from mythril.support.model import get_model

mythril/analysis/module/modules/arbitrary_write.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"""This module contains the detection code for arbitrary storage write."""
22

33
import logging
4+
45
from mythril.analysis.module.base import DetectionModule, EntryPoint
56
from mythril.analysis.potential_issues import (
6-
get_potential_issues_annotation,
77
PotentialIssue,
8+
get_potential_issues_annotation,
89
)
9-
1010
from mythril.analysis.swc_data import WRITE_TO_ARBITRARY_STORAGE
1111
from mythril.laser.ethereum.state.global_state import GlobalState
1212
from mythril.laser.smt import symbol_factory

mythril/analysis/module/modules/delegatecall.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
import logging
44
from typing import List
55

6+
from mythril.analysis.module.base import DetectionModule, EntryPoint
67
from mythril.analysis.potential_issues import (
7-
get_potential_issues_annotation,
88
PotentialIssue,
9+
get_potential_issues_annotation,
910
)
1011
from mythril.analysis.swc_data import DELEGATECALL_TO_UNTRUSTED_CONTRACT
12+
from mythril.exceptions import UnsatError
13+
from mythril.laser.ethereum.state.global_state import GlobalState
1114
from mythril.laser.ethereum.transaction.symbolic import ACTORS
1215
from mythril.laser.ethereum.transaction.transaction_models import (
1316
ContractCreationTransaction,
1417
)
15-
from mythril.analysis.module.base import DetectionModule, EntryPoint
16-
from mythril.exceptions import UnsatError
17-
from mythril.laser.ethereum.state.global_state import GlobalState
18-
from mythril.laser.smt import symbol_factory, UGT
18+
from mythril.laser.smt import UGT, symbol_factory
1919

2020
log = logging.getLogger(__name__)
2121

mythril/analysis/module/modules/dependence_on_origin.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33

44
import logging
55
from copy import copy
6+
from typing import List
7+
8+
from mythril.analysis import solver
69
from mythril.analysis.issue_annotation import IssueAnnotation
710
from mythril.analysis.module.base import DetectionModule, EntryPoint
811
from mythril.analysis.report import Issue
9-
from mythril.exceptions import UnsatError
10-
from mythril.analysis import solver
1112
from mythril.analysis.swc_data import TX_ORIGIN_USAGE
13+
from mythril.exceptions import UnsatError
1214
from mythril.laser.ethereum.state.global_state import GlobalState
1315
from mythril.laser.smt import And
14-
from typing import List
1516

1617
log = logging.getLogger(__name__)
1718

mythril/analysis/module/modules/dependence_on_predictable_vars.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
dependence."""
33

44
import logging
5+
from typing import List, cast
56

7+
from mythril.analysis import solver
68
from mythril.analysis.issue_annotation import IssueAnnotation
79
from mythril.analysis.module.base import DetectionModule, EntryPoint
10+
from mythril.analysis.module.module_helpers import is_prehook
811
from mythril.analysis.report import Issue
9-
from mythril.exceptions import UnsatError
10-
from mythril.analysis import solver
11-
from mythril.laser.smt import And, ULT, symbol_factory
1212
from mythril.analysis.swc_data import TIMESTAMP_DEPENDENCE, WEAK_RANDOMNESS
13-
from mythril.analysis.module.module_helpers import is_prehook
14-
from mythril.laser.ethereum.state.global_state import GlobalState
13+
from mythril.exceptions import UnsatError
1514
from mythril.laser.ethereum.state.annotation import StateAnnotation
16-
from typing import cast, List
15+
from mythril.laser.ethereum.state.global_state import GlobalState
16+
from mythril.laser.smt import ULT, And, symbol_factory
1717

1818
log = logging.getLogger(__name__)
1919

mythril/analysis/module/modules/ether_thief.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
import logging
55
from copy import copy
66

7+
from mythril.analysis import solver
78
from mythril.analysis.module.base import DetectionModule, EntryPoint
89
from mythril.analysis.potential_issues import (
9-
get_potential_issues_annotation,
1010
PotentialIssue,
11+
get_potential_issues_annotation,
1112
)
12-
from mythril.laser.ethereum.transaction.symbolic import ACTORS
1313
from mythril.analysis.swc_data import UNPROTECTED_ETHER_WITHDRAWAL
14-
from mythril.laser.ethereum.state.global_state import GlobalState
15-
from mythril.analysis import solver
1614
from mythril.exceptions import UnsatError
15+
from mythril.laser.ethereum.state.global_state import GlobalState
16+
from mythril.laser.ethereum.transaction.symbolic import ACTORS
1717
from mythril.laser.smt import UGT
1818

1919
log = logging.getLogger(__name__)

mythril/analysis/module/modules/exceptions.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
"""This module contains the detection code for reachable exceptions."""
22

33
import logging
4+
from typing import List, Optional, cast
45

5-
from typing import cast, List, Optional
66
from mythril.analysis import solver
77
from mythril.analysis.issue_annotation import IssueAnnotation
88
from mythril.analysis.module.base import DetectionModule, EntryPoint
99
from mythril.analysis.report import Issue
1010
from mythril.analysis.swc_data import ASSERT_VIOLATION
1111
from mythril.exceptions import UnsatError
12-
13-
from mythril.laser.ethereum.state.global_state import GlobalState
14-
from mythril.laser.ethereum.state.annotation import StateAnnotation
1512
from mythril.laser.ethereum import util
13+
from mythril.laser.ethereum.state.annotation import StateAnnotation
14+
from mythril.laser.ethereum.state.global_state import GlobalState
1615
from mythril.laser.smt import And
17-
1816
from mythril.support.support_utils import get_code_hash
1917

2018
log = logging.getLogger(__name__)

mythril/analysis/module/modules/external_calls.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
"""This module contains the detection code for potentially insecure low-level
22
calls."""
33

4+
import logging
5+
from copy import copy
6+
47
from mythril.analysis import solver
8+
from mythril.analysis.module.base import DetectionModule, EntryPoint
59
from mythril.analysis.potential_issues import (
610
PotentialIssue,
711
get_potential_issues_annotation,
812
)
913
from mythril.analysis.swc_data import REENTRANCY
10-
from mythril.laser.ethereum.state.constraints import Constraints
11-
from mythril.laser.ethereum.transaction.symbolic import ACTORS
12-
from mythril.analysis.module.base import DetectionModule, EntryPoint
13-
from mythril.laser.smt import UGT, symbol_factory, Or, BitVec
14+
from mythril.exceptions import UnsatError
1415
from mythril.laser.ethereum.natives import PRECOMPILE_COUNT
16+
from mythril.laser.ethereum.state.constraints import Constraints
1517
from mythril.laser.ethereum.state.global_state import GlobalState
16-
from mythril.exceptions import UnsatError
17-
from copy import copy
18-
import logging
18+
from mythril.laser.ethereum.transaction.symbolic import ACTORS
19+
from mythril.laser.smt import UGT, BitVec, Or, symbol_factory
1920

2021
log = logging.getLogger(__name__)
2122

mythril/analysis/module/modules/integer.py

+14-13
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
11
"""This module contains the detection code for integer overflows and
22
underflows."""
33

4-
from math import log2, ceil
5-
from typing import cast, List, Set
4+
import logging
5+
from copy import copy
6+
from math import ceil, log2
7+
from typing import List, Set, cast
8+
69
from mythril.analysis import solver
710
from mythril.analysis.issue_annotation import IssueAnnotation
11+
from mythril.analysis.module.base import DetectionModule, EntryPoint
812
from mythril.analysis.report import Issue
913
from mythril.analysis.swc_data import INTEGER_OVERFLOW_AND_UNDERFLOW
1014
from mythril.exceptions import UnsatError
11-
from mythril.laser.ethereum.state.global_state import GlobalState
1215
from mythril.laser.ethereum.state.annotation import StateAnnotation
13-
from mythril.analysis.module.base import DetectionModule, EntryPoint
14-
from copy import copy
15-
16+
from mythril.laser.ethereum.state.global_state import GlobalState
1617
from mythril.laser.smt import (
18+
And,
19+
BitVec,
1720
BVAddNoOverflow,
18-
BVSubNoUnderflow,
1921
BVMulNoOverflow,
20-
BitVec,
22+
BVSubNoUnderflow,
23+
Expression,
2124
If,
22-
symbol_factory,
2325
Not,
24-
Expression,
26+
symbol_factory,
27+
)
28+
from mythril.laser.smt import (
2529
SMTBool as Bool,
26-
And,
2730
)
2831

29-
import logging
30-
3132
log = logging.getLogger(__name__)
3233

3334

mythril/analysis/module/modules/multiple_sends.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
"""This module contains the detection code to find multiple sends occurring in
22
a single transaction."""
33

4+
import logging
45
from copy import copy
5-
from typing import cast, List
6+
from typing import List, cast
7+
68
from mythril.analysis.issue_annotation import IssueAnnotation
9+
from mythril.analysis.module.base import DetectionModule, EntryPoint
710
from mythril.analysis.report import Issue
8-
from mythril.analysis.solver import get_transaction_sequence, UnsatError
11+
from mythril.analysis.solver import UnsatError, get_transaction_sequence
912
from mythril.analysis.swc_data import MULTIPLE_SENDS
10-
from mythril.analysis.module.base import DetectionModule, EntryPoint
1113
from mythril.laser.ethereum.state.annotation import StateAnnotation
1214
from mythril.laser.ethereum.state.global_state import GlobalState
1315
from mythril.laser.smt import And
14-
import logging
1516

1617
log = logging.getLogger(__name__)
1718

0 commit comments

Comments
 (0)