91
91
from tempfile import TemporaryDirectory
92
92
from typing import Optional
93
93
94
- statistics = defaultdict [ str , int ] (int )
94
+ statistics = defaultdict (int )
95
95
96
96
expected_failure_statistics = {
97
97
"missing_tests" : 10 ,
@@ -268,12 +268,12 @@ class Tags:
268
268
"""
269
269
270
270
def __init__ (self , tag_string : str ) -> None :
271
- self .map = defaultdict [ str , str ] (
271
+ self .map = defaultdict (
272
272
lambda : "" ,
273
273
[split_first (tag , "=" ) for tag in tag_string .split (";" )],
274
274
)
275
275
276
- self .opt_test_language : Optional [ TestLanguage ] = None
276
+ self .opt_test_language = None
277
277
if "std" in self .map :
278
278
self .opt_test_language = TestLanguage (self .map ["std" ])
279
279
self .map .pop ("std" )
@@ -318,7 +318,7 @@ def get_as_cpp_raw_string(self) -> str:
318
318
return f'R"cpp({ self .match_str } )cpp"'
319
319
320
320
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 :
322
322
for arg in args :
323
323
if arg == "-ObjC" :
324
324
args .remove (arg )
@@ -337,7 +337,7 @@ class CompileArgs:
337
337
args: All other arguments
338
338
"""
339
339
340
- def __init__ (self , args : list [ str ] ) -> None :
340
+ def __init__ (self , args : list ) -> None :
341
341
self .lang_spec = TestLanguage (get_lang_spec_and_remove_from_list (args ))
342
342
self .args = args
343
343
@@ -385,7 +385,7 @@ def get_any_valid_std_specified(lang_spec: str) -> str:
385
385
return lang_spec
386
386
387
387
388
- def get_with_lang_spec (args : CompileArgs ) -> list [ str ] :
388
+ def get_with_lang_spec (args : CompileArgs ) -> list :
389
389
"""Construct compiler arguments from a CompileArgs instance
390
390
391
391
Args:
@@ -427,8 +427,8 @@ def get_with_lang_spec(args: CompileArgs) -> list[str]:
427
427
428
428
def can_code_compile (
429
429
code : str ,
430
- headers : list [ tuple [ str , str ]] ,
431
- compile_commands : Optional [ CompileArgs ] ,
430
+ headers : list ,
431
+ compile_commands ,
432
432
) -> bool :
433
433
"""Check if the code can compile using the provided arguments.
434
434
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):
552
552
self .cases : list [tuple [list [Matcher ], list [Match ]]] = []
553
553
self .code : str = ""
554
554
self .headers : list [tuple [str , str ]] = []
555
- self .compile_args : Optional [ CompileArgs ] = None
555
+ self .compile_args = None
556
556
557
- def get_last_case (self ) -> tuple [ list [ Matcher ], list [ Match ]] :
557
+ def get_last_case (self ) -> tuple :
558
558
return self .cases [- 1 ]
559
559
560
560
def add_case (self ):
@@ -720,7 +720,7 @@ class ParsingContext(Enum):
720
720
NoMatch = 6
721
721
722
722
723
- def split_first (data : str , delim : str ) -> tuple [ str , str ] :
723
+ def split_first (data : str , delim : str ) -> tuple :
724
724
pos = data .find (delim )
725
725
if pos == - 1 :
726
726
return (data , "" )
@@ -770,8 +770,8 @@ class CommentedMatcher:
770
770
771
771
def __init__ (
772
772
self ,
773
- comment : list [ tuple [ int , str ]] ,
774
- matcher : list [ tuple [ int , str ]] ,
773
+ comment : list ,
774
+ matcher : list ,
775
775
):
776
776
self .comment = comment
777
777
self .matcher = matcher
@@ -789,10 +789,10 @@ class BlockParser:
789
789
790
790
def __init__ (self , data : CommentedMatcher , input_file : Path ):
791
791
self .input_file = input_file
792
- self .cases = list [ TestCase ] ()
792
+ self .cases = list ()
793
793
self .current_line = data .comment [0 ][0 ]
794
794
self .data = "\n " .join ([line [1 ] for line in data .comment ])
795
- self .diagnostics = list [ str ] ()
795
+ self .diagnostics = list ()
796
796
797
797
def advance (self ) -> ParsingContext :
798
798
"""Find the next doxygen command to be parsed and return the
@@ -810,7 +810,7 @@ def advance(self) -> ParsingContext:
810
810
"\\ nomatch{" : ParsingContext .NoMatch ,
811
811
}
812
812
813
- matches = list [ tuple [ int , ParsingContext , str ]] ()
813
+ matches = list ()
814
814
815
815
for tag , ctx in begin_tags .items ():
816
816
match = self .data .find (tag )
@@ -887,7 +887,7 @@ def visit_compile_args(self):
887
887
[split_arg for arg in args .split (";" ) for split_arg in arg .split (" " )],
888
888
)
889
889
890
- def build_matcher (self ) -> Optional [ Matcher ] :
890
+ def build_matcher (self ):
891
891
end = find_matching_closing_rbrace (self .data , 0 , 0 )
892
892
tag_separator = self .data .find ("$" )
893
893
tags = Tags ("" )
@@ -1018,10 +1018,8 @@ def parse_block(data: CommentedMatcher, input_file: Path) -> BlockParser:
1018
1018
return parser
1019
1019
1020
1020
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 = ([], [])
1025
1023
1026
1024
for parsed_block in [parse_block (block , input_file ) for block in data ]:
1027
1025
result [0 ].extend (parsed_block .cases )
@@ -1031,9 +1029,9 @@ def parse(
1031
1029
1032
1030
1033
1031
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 = []
1037
1035
1038
1036
start_new_group_on_comment = True
1039
1037
for line_nr , line in enumerate (enumerated_lines , start = 1 ):
0 commit comments