Skip to content

Commit e2557a0

Browse files
committed
Fix formatting
1 parent ca2cfa2 commit e2557a0

File tree

4 files changed

+42
-18
lines changed

4 files changed

+42
-18
lines changed

crackers_python/crackers/crackers_types.pyi

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
11
from typing import Optional, Union, Callable, Iterable
2-
3-
from z3 import z3
4-
52
from .jingle_types import State, ModeledBlock, ResolvedVarNode
6-
from ._internal.crackers import CrackersLogLevel
7-
from ._internal.crackers import SynthesisSelectionStrategy
3+
from z3 import z3 # type: ignore
4+
5+
__all__ = [
6+
"AssignmentModel",
7+
"ConstraintConfig",
8+
"CrackersConfig",
9+
"CrackersLogLevel",
10+
"DecisionResult",
11+
"GadgetLibraryConfig",
12+
"MemoryEqualityConstraint",
13+
"MetaConfig",
14+
"PointerRange",
15+
"PointerRangeConstraints",
16+
"SleighConfig",
17+
"SpecificationConfig",
18+
"StateEqualityConstraint",
19+
"SynthesisConfig",
20+
"SynthesisParams",
21+
"SynthesisSelectionStrategy",
22+
"DecisionResultType",
23+
"StateConstraintGenerator",
24+
"TransitionConstraintGenerator"
25+
]
826

927
class AssignmentModel:
1028
def eval_bv(self, bv: z3.BitVecRef, model_completion: bool) -> z3.BitVecRef: ...
@@ -42,11 +60,11 @@ class CrackersConfig:
4260

4361

4462
class CrackersLogLevel:
45-
Debug = CrackersLogLevel.Debug
46-
Error = CrackersLogLevel.Error
47-
Info = CrackersLogLevel.Info
48-
Trace = CrackersLogLevel.Trace
49-
Warn = CrackersLogLevel.Warn
63+
Debug: int
64+
Error: int
65+
Info: int
66+
Trace: int
67+
Warn: int
5068

5169

5270

@@ -92,8 +110,8 @@ class StateEqualityConstraint:
92110
memory: Optional[MemoryEqualityConstraint]
93111

94112
class SynthesisSelectionStrategy:
95-
SatStrategy = SynthesisSelectionStrategy.SatStrategy
96-
OptimizeStrategy = SynthesisSelectionStrategy.OptimizeStrategy
113+
SatStrategy: int
114+
OptimizeStrategy: int
97115

98116
class SynthesisConfig:
99117
strategy: SynthesisSelectionStrategy
@@ -118,13 +136,13 @@ class DecisionResult:
118136
Unsat : PythonDecisionResult_Unsat
119137

120138

121-
DecisionResultType = Union[DecisionResult.AssignmentFound, DecisionResult.Unsat]
139+
DecisionResultType = Union["PythonDecisionResult_AssignmentFound", "PythonDecisionResult_Unsat"]
122140

123141
StateConstraintGenerator = Callable[[State, int], z3.BitVecRef]
124142
TransitionConstraintGenerator = Callable[[ModeledBlock], z3.BitVecRef]
125143

126144
class SynthesisParams:
127-
def run(self) -> DecisionResultType: ...
145+
def run(self) -> "DecisionResultType": ...
128146
def add_precondition(self, fn: StateConstraintGenerator): ...
129147
def add_postcondition(self, fn: StateConstraintGenerator): ...
130148
def add_transition_constraint(self, fn: TransitionConstraintGenerator): ...

crackers_python/crackers/jingle_types.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Optional, Iterable, List
22

3-
from z3 import z3
3+
from z3 import z3 # type: ignore
44

55

66
class Instruction:
@@ -40,7 +40,7 @@ class SleighContext:
4040
Represents a Sleigh context in python.
4141
"""
4242

43-
def __init__(self, binary_path: str, ghidra: str) -> SleighContext: ...
43+
def __init__(self, binary_path: str, ghidra: str) -> None: ...
4444

4545
def instruction_at(self, offset: int) -> Optional[Instruction]: ...
4646

@@ -50,7 +50,7 @@ class SleighContext:
5050

5151

5252
class State:
53-
def __init__(self, jingle: SleighContext) -> State: ...
53+
def __init__(self, jingle: SleighContext) -> None: ...
5454

5555
def direct_varnode(self, space: str, offset: int, size: int) -> ResolvedVarNode: ...
5656

crackers_python/mypy.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[mypy]
2+
# Global mypy options can go here
3+
4+
[mypy-z3.*]
5+
ignore_missing_imports = True

crackers_python/pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ module-name = "crackers._internal"
2626
dev = [
2727
"ruff",
2828
"mypy",
29-
"nox"
29+
"nox",
30+
"z3-solver"
3031
]

0 commit comments

Comments
 (0)