Skip to content

Commit 5ffa1f3

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 1c16253 commit 5ffa1f3

3 files changed

Lines changed: 16 additions & 14 deletions

File tree

pypcode/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
import os.path
77
import xml.etree.ElementTree as ET
88
from enum import IntEnum
9-
from typing import cast, Generator, Sequence, Mapping
9+
from typing import cast
10+
from collections.abc import Generator, Sequence, Mapping
1011

1112
from .__version__ import __version__
1213

scripts/benchmark.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
import time
1818
from dataclasses import dataclass
1919

20-
from typing import cast, Any, Callable, Dict, Iterable, List, Tuple
20+
from typing import cast, Any, Dict, List, Tuple
21+
from collections.abc import Callable, Iterable
2122

2223
logging.basicConfig(level=logging.INFO)
2324
log = logging.getLogger(__name__)
@@ -85,9 +86,9 @@ def get_file_hash(binary_path: str) -> str:
8586
return d
8687

8788

88-
def get_blocks(binary_path: str) -> List[Block]:
89+
def get_blocks(binary_path: str) -> list[Block]:
8990
blocks_file_path = f"blocks_{get_file_hash(binary_path)[0:8]}.cache"
90-
blocks: List[Block] = []
91+
blocks: list[Block] = []
9192

9293
if not os.path.exists(blocks_file_path):
9394
log.info("Recovering blocks from CFG...")
@@ -121,7 +122,7 @@ def get_blocks(binary_path: str) -> List[Block]:
121122
return blocks
122123

123124

124-
def benchmark_pypcode(blocks: List[Block], iter_ops: bool = False, iter_varnodes: bool = False) -> BenchmarkResult:
125+
def benchmark_pypcode(blocks: list[Block], iter_ops: bool = False, iter_varnodes: bool = False) -> BenchmarkResult:
125126
assert pypcode is not None
126127

127128
start_time = time.time()
@@ -144,7 +145,7 @@ def benchmark_pypcode(blocks: List[Block], iter_ops: bool = False, iter_varnodes
144145
return BenchmarkResult(startup_duration, translation_duration)
145146

146147

147-
def benchmark_pypcode_disassembly(blocks: List[Block]) -> BenchmarkResult:
148+
def benchmark_pypcode_disassembly(blocks: list[Block]) -> BenchmarkResult:
148149
assert pypcode is not None
149150

150151
start_time = time.time()
@@ -161,7 +162,7 @@ def benchmark_pypcode_disassembly(blocks: List[Block]) -> BenchmarkResult:
161162
return BenchmarkResult(startup_duration, translation_duration)
162163

163164

164-
def benchmark_pyvex(blocks: List[Block], **vex_args) -> BenchmarkResult:
165+
def benchmark_pyvex(blocks: list[Block], **vex_args) -> BenchmarkResult:
165166
assert pyvex is not None
166167

167168
start_time = time.time()
@@ -176,7 +177,7 @@ def benchmark_pyvex(blocks: List[Block], **vex_args) -> BenchmarkResult:
176177
return BenchmarkResult(startup_duration, translation_duration)
177178

178179

179-
def benchmark_capstone(blocks: List[Block], lite: bool = False) -> BenchmarkResult:
180+
def benchmark_capstone(blocks: list[Block], lite: bool = False) -> BenchmarkResult:
180181
assert capstone is not None
181182

182183
start_time = time.time()
@@ -199,9 +200,9 @@ def benchmark_capstone(blocks: List[Block], lite: bool = False) -> BenchmarkResu
199200

200201

201202
def gen_benchmarks_from_configurations(
202-
name: str, benchmark_func: Callable, configurations: List[Dict[str, Any]]
203-
) -> List[Tuple[str, Callable]]:
204-
benchmarks: List[Tuple[str, Callable]] = []
203+
name: str, benchmark_func: Callable, configurations: list[dict[str, Any]]
204+
) -> list[tuple[str, Callable]]:
205+
benchmarks: list[tuple[str, Callable]] = []
205206
for config in configurations:
206207
name_append = ""
207208
if config:
@@ -239,7 +240,7 @@ def main() -> None:
239240
for name, version, import_duration in imports:
240241
log.info("%s v%s took %.2f ms to import", name, version, import_duration * 1000)
241242

242-
benchmarks: List[Tuple[str, Callable]] = []
243+
benchmarks: list[tuple[str, Callable]] = []
243244
if HAVE_CAPSTONE and "capstone" not in args.skip:
244245
benchmarks.extend(
245246
gen_benchmarks_from_configurations(
@@ -300,7 +301,7 @@ def main() -> None:
300301
log.info("Benchmark includes %d blocks totaling %.1f KiB", num_blocks, blocks_total_size / 1024)
301302

302303
gc.collect()
303-
results: List[Tuple[str, BenchmarkResult]] = []
304+
results: list[tuple[str, BenchmarkResult]] = []
304305
gc.disable()
305306
for name, benchmark in benchmarks:
306307
log.info("Benchmarking %s performance...", name)

tests/test_pypcode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
log = logging.getLogger(__name__)
2828

2929

30-
def get_imarks(translation: Translation) -> List[PcodeOp]:
30+
def get_imarks(translation: Translation) -> list[PcodeOp]:
3131
return [op for op in translation.ops if op.opcode == OpCode.IMARK]
3232

3333

0 commit comments

Comments
 (0)