41
41
same line, but it is far from perfect (in either direction).
42
42
"""
43
43
44
+ from __future__ import annotations
45
+
44
46
import codecs
45
47
import collections
46
48
import copy
57
59
import xml .etree .ElementTree
58
60
59
61
# if empty, use defaults
60
- _valid_extensions = set ()
62
+ _valid_extensions : set [ str ] = set ()
61
63
62
64
__VERSION__ = "2.0.1"
63
65
830
832
]
831
833
832
834
# Replacement macros for CHECK/DCHECK/EXPECT_TRUE/EXPECT_FALSE
833
- _CHECK_REPLACEMENT = {macro_var : {} for macro_var in _CHECK_MACROS }
835
+ _CHECK_REPLACEMENT : dict [ str , dict [ str , str ]] = {macro_var : {} for macro_var in _CHECK_MACROS }
834
836
835
837
for op , replacement in [
836
838
("==" , "EQ" ),
934
936
935
937
# {str, set(int)}: a map from error categories to sets of linenumbers
936
938
# on which those errors are expected and should be suppressed.
937
- _error_suppressions = {}
939
+ _error_suppressions : dict [ str , set [ int ]] = {}
938
940
939
941
# The root directory used for deriving header guard CPP variable.
940
942
# This is set by --root flag.
964
966
965
967
# Treat all headers starting with 'h' equally: .h, .hpp, .hxx etc.
966
968
# This is set by --headers flag.
967
- _hpp_headers = set ()
969
+ _hpp_headers : set [ str ] = set ()
968
970
969
971
970
972
class ErrorSuppressions :
@@ -1034,7 +1036,7 @@ def Clear(self):
1034
1036
self ._open_block_suppression = None
1035
1037
1036
1038
1037
- _error_suppressions = ErrorSuppressions ()
1039
+ _error_suppressions = ErrorSuppressions () # type: ignore[assignment]
1038
1040
1039
1041
1040
1042
def ProcessHppHeadersOption (val ):
@@ -6609,7 +6611,7 @@ def ExpectingFunctionArgs(clean_lines, linenum):
6609
6611
)
6610
6612
6611
6613
6612
- _HEADERS_CONTAINING_TEMPLATES = (
6614
+ _HEADERS_CONTAINING_TEMPLATES : tuple [ tuple [ str , tuple [ str , ...]], ...] = (
6613
6615
("<deque>" , ("deque" ,)),
6614
6616
(
6615
6617
"<functional>" ,
@@ -6705,7 +6707,7 @@ def ExpectingFunctionArgs(clean_lines, linenum):
6705
6707
("<slist>" , ("slist" ,)),
6706
6708
)
6707
6709
6708
- _HEADERS_MAYBE_TEMPLATES = (
6710
+ _HEADERS_MAYBE_TEMPLATES : tuple [ tuple [ str , tuple [ str , ...]], ...] = (
6709
6711
(
6710
6712
"<algorithm>" ,
6711
6713
(
@@ -6721,15 +6723,15 @@ def ExpectingFunctionArgs(clean_lines, linenum):
6721
6723
)
6722
6724
6723
6725
# Non templated types or global objects
6724
- _HEADERS_TYPES_OR_OBJS = (
6726
+ _HEADERS_TYPES_OR_OBJS : tuple [ tuple [ str , tuple [ str , ...]], ...] = (
6725
6727
# String and others are special -- it is a non-templatized type in STL.
6726
6728
("<string>" , ("string" ,)),
6727
6729
("<iostream>" , ("cin" , "cout" , "cerr" , "clog" , "wcin" , "wcout" , "wcerr" , "wclog" )),
6728
6730
("<cstdio>" , ("FILE" , "fpos_t" )),
6729
6731
)
6730
6732
6731
6733
# Non templated functions
6732
- _HEADERS_FUNCTIONS = (
6734
+ _HEADERS_FUNCTIONS : tuple [ tuple [ str , tuple [ str , ...]], ...] = (
6733
6735
(
6734
6736
"<cstdio>" ,
6735
6737
(
@@ -6780,7 +6782,7 @@ def ExpectingFunctionArgs(clean_lines, linenum):
6780
6782
),
6781
6783
)
6782
6784
6783
- _re_pattern_headers_maybe_templates = []
6785
+ _re_pattern_headers_maybe_templates : list [ tuple [ re . Pattern , str , str ]] = []
6784
6786
for _header , _templates in _HEADERS_MAYBE_TEMPLATES :
6785
6787
# Match max<type>(..., ...), max(..., ...), but not foo->max, foo.max or
6786
6788
# 'type::max()'.
@@ -6796,7 +6798,7 @@ def ExpectingFunctionArgs(clean_lines, linenum):
6796
6798
)
6797
6799
6798
6800
# Other scripts may reach in and modify this pattern.
6799
- _re_pattern_templates = []
6801
+ _re_pattern_templates : list [ tuple [ re . Pattern , str , str ]] = []
6800
6802
for _header , _templates in _HEADERS_CONTAINING_TEMPLATES :
6801
6803
_re_pattern_templates .extend (
6802
6804
(
@@ -6807,14 +6809,14 @@ def ExpectingFunctionArgs(clean_lines, linenum):
6807
6809
for _template in _templates
6808
6810
)
6809
6811
6810
- _re_pattern_types_or_objs = []
6812
+ _re_pattern_types_or_objs : list [ tuple [ re . Pattern , object | type , str ]] = []
6811
6813
for _header , _types_or_objs in _HEADERS_TYPES_OR_OBJS :
6812
6814
_re_pattern_types_or_objs .extend (
6813
6815
(re .compile (r"\b" + _type_or_obj + r"\b" ), _type_or_obj , _header )
6814
6816
for _type_or_obj in _types_or_objs
6815
6817
)
6816
6818
6817
- _re_pattern_functions = []
6819
+ _re_pattern_functions : list [ tuple [ re . Pattern , str , str ]] = []
6818
6820
for _header , _functions in _HEADERS_FUNCTIONS :
6819
6821
# Match printf(..., ...), but not foo->printf, foo.printf or
6820
6822
# 'type::printf()'.
0 commit comments