Skip to content

Commit 09ba145

Browse files
committed
mytype
1 parent 1be1dfa commit 09ba145

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

fuzz/command_util.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
import logging
55
import time
66
from pathlib import Path
7-
from typing import Optional, Tuple, List
7+
from typing import Optional
88
from returns.maybe import Maybe
99
from errors import CommandError
1010

1111
def _run_subprocess(
1212
cmd: str,
13-
cwd: Optional[Path] = None, # 修复:添加 Optional 类型
13+
cwd: Optional[Path] = None,
1414
capture_output: bool = False,
15-
timeout: Optional[int] = None, # 修复:添加 Optional 类型
16-
logger: Optional[logging.Logger] = None, # 修复:添加 Optional 类型
17-
) -> Tuple[int, List[str]]: # 建议使用 Tuple 替代 tuple
15+
timeout: Optional[int] = None,
16+
logger: Optional[logging.Logger] = None,
17+
) -> tuple[int, list[str]]:
1818
"""
1919
低层执行子进程命令
2020
- capture_output=True:捕获 stdout,返回输出列表
@@ -33,12 +33,12 @@ def _run_subprocess(
3333
errors="replace",
3434
)
3535

36-
output_lines: List[str] = []
36+
output_lines: list[str] = []
3737
start_time = time.time()
3838

3939
try:
4040
if capture_output:
41-
# 确保 stdout 不是 None
41+
4242
if process.stdout is None:
4343
raise RuntimeError("stdout is unexpectedly None in capture mode")
4444

@@ -52,7 +52,7 @@ def _run_subprocess(
5252
elif process.poll() is not None:
5353
break
5454

55-
# 处理超时逻辑
55+
# Handle timeout logic
5656
if timeout and (time.time() - start_time) > timeout:
5757
if logger:
5858
logger.error(f"⌛ 命令超时,耗时 {timeout} 秒")
@@ -64,7 +64,7 @@ def _run_subprocess(
6464
return -1, output_lines
6565
time.sleep(0.05)
6666
else:
67-
# 不捕获输出,直接等待结束
67+
6868
process.wait(timeout=timeout)
6969

7070
except Exception as e:
@@ -80,7 +80,7 @@ def run_command_build_fuzz(
8080
cmd: str,
8181
oss_fuzz_dir: Path,
8282
project: str = "",
83-
allowed_exit_codes: Maybe[List[int]] = Maybe.empty,
83+
allowed_exit_codes: Maybe[list[int]] = Maybe.empty,
8484
skip_yes: bool = False
8585
) -> int:
8686
"""build_fuzz.py 中使用的 run_command,简化版,抛异常"""
@@ -99,7 +99,7 @@ def run_command_fuzz_all_targets(
9999
cmd: str,
100100
log_msg: str,
101101
logger: logging.Logger,
102-
allowed_exit_codes: Maybe[List[int]] = Maybe.empty,
102+
allowed_exit_codes: Maybe[list[int]] = Maybe.empty,
103103
timeout: int = 3600,
104104
) -> bool:
105105
"""run_fuzz_all_targets_print1.py 中使用,带实时日志与超时,返回 bool"""

0 commit comments

Comments
 (0)