Skip to content

Commit 6f7ac62

Browse files
Fix issues reported by mypy.
1 parent 50547e8 commit 6f7ac62

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

clang/utils/aarch64_builtins_test_generator.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@
1919
import argparse
2020
import json
2121
import re
22+
import sys
2223
from collections import defaultdict
2324
from dataclasses import dataclass
2425
from enum import Enum
2526
from itertools import product
2627
from pathlib import Path
27-
from typing import Dict, Iterable, List, Sequence, Tuple
28+
from typing import Any, Dict, Iterable, List, Sequence, Tuple
29+
30+
assert sys.version_info >= (3, 10), "Only Python 3.10+ is supported."
2831

2932

3033
# Are we testing arm_sve.h or arm_sme.h based builtins.
@@ -156,7 +159,7 @@ def make_arg_for_type(ty: str) -> Tuple[str, str]:
156159
# Specifically the expected input is of the form:
157160
# feat1,feat2,...(feat3 | feat4 | ...),...
158161
def expand_feature_guard(
159-
guard: str, flags: str, base_feature: str = None
162+
guard: str, flags: Sequence[str], base_feature: str = ""
160163
) -> list[set[str]]:
161164
"""
162165
Expand a guard expression where ',' = AND and '|' = OR, with parentheses
@@ -389,7 +392,7 @@ def build_calls_for_group(builtins: Iterable[str]) -> Tuple[List[str], List[str]
389392
"""
390393
var_decls: List[str] = []
391394
seen_types: set[str] = set()
392-
calls: List[Tuple[str, str]] = []
395+
calls: List[str] = []
393396

394397
for decl in builtins:
395398
fn, param_types = parse_builtin_declaration(decl)
@@ -411,14 +414,15 @@ def build_calls_for_group(builtins: Iterable[str]) -> Tuple[List[str], List[str]
411414
return var_decls, calls
412415

413416

414-
def gen_streaming_guard_tests(mode: MODE, json_path: Path, out_dir: Path) -> None:
417+
def gen_streaming_guard_tests(mode: Mode, json_path: Path, out_dir: Path) -> None:
415418
"""Generate a set of Clang Sema test files to ensure SVE/SME builtins are
416419
callable based on the function type, or the required diagnostic is emitted.
417420
"""
418421
try:
419422
data = json.loads(json_path.read_text())
420423
except json.JSONDecodeError as e:
421-
ap.error(f"Failed to parse JSON {args.json}: {e}")
424+
print(f"Failed to parse JSON {json_path}: {e}", file=sys.stderr)
425+
return
422426

423427
# Group by (guard, streaming_guard)
424428
by_guard: Dict[BuiltinContext, List[str]] = defaultdict(list)
@@ -468,7 +472,7 @@ def gen_streaming_guard_tests(mode: MODE, json_path: Path, out_dir: Path) -> Non
468472
else:
469473
print(output)
470474

471-
return 0
475+
return
472476

473477

474478
# --- Main -------------------------------------------------------------------

0 commit comments

Comments
 (0)