Skip to content

Commit d5b33fd

Browse files
committed
[clang][test][NFC] fix for python version requirements
Fix for the buildbot failure due to lower python versions not supporting some types to be subscripted. Tested with python3.8.
1 parent 64d7057 commit d5b33fd

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

clang/utils/generate_ast_matcher_doc_tests.py

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
from tempfile import TemporaryDirectory
9292
from typing import Optional
9393

94-
statistics = defaultdict[str, int](int)
94+
statistics = defaultdict(int)
9595

9696
expected_failure_statistics = {
9797
"missing_tests": 10,
@@ -268,12 +268,12 @@ class Tags:
268268
"""
269269

270270
def __init__(self, tag_string: str) -> None:
271-
self.map = defaultdict[str, str](
271+
self.map = defaultdict(
272272
lambda: "",
273273
[split_first(tag, "=") for tag in tag_string.split(";")],
274274
)
275275

276-
self.opt_test_language: Optional[TestLanguage] = None
276+
self.opt_test_language = None
277277
if "std" in self.map:
278278
self.opt_test_language = TestLanguage(self.map["std"])
279279
self.map.pop("std")
@@ -318,7 +318,7 @@ def get_as_cpp_raw_string(self) -> str:
318318
return f'R"cpp({self.match_str})cpp"'
319319

320320

321-
def get_lang_spec_and_remove_from_list(args: list[str]) -> str:
321+
def get_lang_spec_and_remove_from_list(args: list) -> str:
322322
for arg in args:
323323
if arg == "-ObjC":
324324
args.remove(arg)
@@ -337,7 +337,7 @@ class CompileArgs:
337337
args: All other arguments
338338
"""
339339

340-
def __init__(self, args: list[str]) -> None:
340+
def __init__(self, args: list) -> None:
341341
self.lang_spec = TestLanguage(get_lang_spec_and_remove_from_list(args))
342342
self.args = args
343343

@@ -385,7 +385,7 @@ def get_any_valid_std_specified(lang_spec: str) -> str:
385385
return lang_spec
386386

387387

388-
def get_with_lang_spec(args: CompileArgs) -> list[str]:
388+
def get_with_lang_spec(args: CompileArgs) -> list:
389389
"""Construct compiler arguments from a CompileArgs instance
390390
391391
Args:
@@ -427,8 +427,8 @@ def get_with_lang_spec(args: CompileArgs) -> list[str]:
427427

428428
def can_code_compile(
429429
code: str,
430-
headers: list[tuple[str, str]],
431-
compile_commands: Optional[CompileArgs],
430+
headers: list,
431+
compile_commands,
432432
) -> bool:
433433
"""Check if the code can compile using the provided arguments.
434434
This is used to determine if a code snippet could actually compile in
@@ -552,9 +552,9 @@ def __init__(self, input_file: Path, line: int):
552552
self.cases: list[tuple[list[Matcher], list[Match]]] = []
553553
self.code: str = ""
554554
self.headers: list[tuple[str, str]] = []
555-
self.compile_args: Optional[CompileArgs] = None
555+
self.compile_args = None
556556

557-
def get_last_case(self) -> tuple[list[Matcher], list[Match]]:
557+
def get_last_case(self) -> tuple:
558558
return self.cases[-1]
559559

560560
def add_case(self):
@@ -720,7 +720,7 @@ class ParsingContext(Enum):
720720
NoMatch = 6
721721

722722

723-
def split_first(data: str, delim: str) -> tuple[str, str]:
723+
def split_first(data: str, delim: str) -> tuple:
724724
pos = data.find(delim)
725725
if pos == -1:
726726
return (data, "")
@@ -770,8 +770,8 @@ class CommentedMatcher:
770770

771771
def __init__(
772772
self,
773-
comment: list[tuple[int, str]],
774-
matcher: list[tuple[int, str]],
773+
comment: list,
774+
matcher: list,
775775
):
776776
self.comment = comment
777777
self.matcher = matcher
@@ -789,10 +789,10 @@ class BlockParser:
789789

790790
def __init__(self, data: CommentedMatcher, input_file: Path):
791791
self.input_file = input_file
792-
self.cases = list[TestCase]()
792+
self.cases = list()
793793
self.current_line = data.comment[0][0]
794794
self.data = "\n".join([line[1] for line in data.comment])
795-
self.diagnostics = list[str]()
795+
self.diagnostics = list()
796796

797797
def advance(self) -> ParsingContext:
798798
"""Find the next doxygen command to be parsed and return the
@@ -810,7 +810,7 @@ def advance(self) -> ParsingContext:
810810
"\\nomatch{": ParsingContext.NoMatch,
811811
}
812812

813-
matches = list[tuple[int, ParsingContext, str]]()
813+
matches = list()
814814

815815
for tag, ctx in begin_tags.items():
816816
match = self.data.find(tag)
@@ -887,7 +887,7 @@ def visit_compile_args(self):
887887
[split_arg for arg in args.split(";") for split_arg in arg.split(" ")],
888888
)
889889

890-
def build_matcher(self) -> Optional[Matcher]:
890+
def build_matcher(self):
891891
end = find_matching_closing_rbrace(self.data, 0, 0)
892892
tag_separator = self.data.find("$")
893893
tags = Tags("")
@@ -1018,10 +1018,8 @@ def parse_block(data: CommentedMatcher, input_file: Path) -> BlockParser:
10181018
return parser
10191019

10201020

1021-
def parse(
1022-
data: list[CommentedMatcher], input_file: Path
1023-
) -> tuple[list[TestCase], list[str]]:
1024-
result: tuple[list[TestCase], list[str]] = ([], [])
1021+
def parse(data: list, input_file: Path) -> tuple:
1022+
result: tuple = ([], [])
10251023

10261024
for parsed_block in [parse_block(block, input_file) for block in data]:
10271025
result[0].extend(parsed_block.cases)
@@ -1031,9 +1029,9 @@ def parse(
10311029

10321030

10331031
def group_doc_comment_and_followed_code(
1034-
enumerated_lines: list[str],
1035-
) -> list[CommentedMatcher]:
1036-
result: list[CommentedMatcher] = []
1032+
enumerated_lines: list,
1033+
) -> list:
1034+
result: list = []
10371035

10381036
start_new_group_on_comment = True
10391037
for line_nr, line in enumerate(enumerated_lines, start=1):

0 commit comments

Comments
 (0)