@@ -755,7 +755,7 @@ def _verify_property(stub: nodes.Decorator, runtime: Any) -> Iterator[str]:
755
755
# It's enough like a property...
756
756
return
757
757
# Sometimes attributes pretend to be properties, for instance, to express that they
758
- # are read only. So whitelist if runtime_type matches the return type of stub.
758
+ # are read only. So allowlist if runtime_type matches the return type of stub.
759
759
runtime_type = get_mypy_type_of_runtime_value (runtime )
760
760
func_type = (
761
761
stub .func .type .ret_type if isinstance (stub .func .type , mypy .types .CallableType ) else None
@@ -1001,14 +1001,14 @@ def get_typeshed_stdlib_modules(custom_typeshed_dir: Optional[str]) -> List[str]
1001
1001
return sorted (modules )
1002
1002
1003
1003
1004
- def get_whitelist_entries ( whitelist_file : str ) -> Iterator [str ]:
1004
+ def get_allowlist_entries ( allowlist_file : str ) -> Iterator [str ]:
1005
1005
def strip_comments (s : str ) -> str :
1006
1006
try :
1007
1007
return s [: s .index ("#" )].strip ()
1008
1008
except ValueError :
1009
1009
return s .strip ()
1010
1010
1011
- with open (whitelist_file ) as f :
1011
+ with open (allowlist_file ) as f :
1012
1012
for line in f .readlines ():
1013
1013
entry = strip_comments (line )
1014
1014
if entry :
@@ -1017,17 +1017,17 @@ def strip_comments(s: str) -> str:
1017
1017
1018
1018
def test_stubs (args : argparse .Namespace ) -> int :
1019
1019
"""This is stubtest! It's time to test the stubs!"""
1020
- # Load the whitelist . This is a series of strings corresponding to Error.object_desc
1021
- # Values in the dict will store whether we used the whitelist entry or not.
1022
- whitelist = {
1020
+ # Load the allowlist . This is a series of strings corresponding to Error.object_desc
1021
+ # Values in the dict will store whether we used the allowlist entry or not.
1022
+ allowlist = {
1023
1023
entry : False
1024
- for whitelist_file in args .whitelist
1025
- for entry in get_whitelist_entries ( whitelist_file )
1024
+ for allowlist_file in args .allowlist
1025
+ for entry in get_allowlist_entries ( allowlist_file )
1026
1026
}
1027
- whitelist_regexes = {entry : re .compile (entry ) for entry in whitelist }
1027
+ allowlist_regexes = {entry : re .compile (entry ) for entry in allowlist }
1028
1028
1029
- # If we need to generate a whitelist , we store Error.object_desc for each error here.
1030
- generated_whitelist = set ()
1029
+ # If we need to generate an allowlist , we store Error.object_desc for each error here.
1030
+ generated_allowlist = set ()
1031
1031
1032
1032
modules = args .modules
1033
1033
if args .check_typeshed :
@@ -1061,37 +1061,37 @@ def set_strict_flags() -> None: # not needed yet
1061
1061
continue
1062
1062
if args .ignore_positional_only and error .is_positional_only_related ():
1063
1063
continue
1064
- if error .object_desc in whitelist :
1065
- whitelist [error .object_desc ] = True
1064
+ if error .object_desc in allowlist :
1065
+ allowlist [error .object_desc ] = True
1066
1066
continue
1067
- is_whitelisted = False
1068
- for w in whitelist :
1069
- if whitelist_regexes [w ].fullmatch (error .object_desc ):
1070
- whitelist [w ] = True
1071
- is_whitelisted = True
1067
+ is_allowlisted = False
1068
+ for w in allowlist :
1069
+ if allowlist_regexes [w ].fullmatch (error .object_desc ):
1070
+ allowlist [w ] = True
1071
+ is_allowlisted = True
1072
1072
break
1073
- if is_whitelisted :
1073
+ if is_allowlisted :
1074
1074
continue
1075
1075
1076
1076
# We have errors, so change exit code, and output whatever necessary
1077
1077
exit_code = 1
1078
- if args .generate_whitelist :
1079
- generated_whitelist .add (error .object_desc )
1078
+ if args .generate_allowlist :
1079
+ generated_allowlist .add (error .object_desc )
1080
1080
continue
1081
1081
print (error .get_description (concise = args .concise ))
1082
1082
1083
- # Print unused whitelist entries
1084
- if not args .ignore_unused_whitelist :
1085
- for w in whitelist :
1083
+ # Print unused allowlist entries
1084
+ if not args .ignore_unused_allowlist :
1085
+ for w in allowlist :
1086
1086
# Don't consider an entry unused if it regex-matches the empty string
1087
- # This allows us to whitelist errors that don't manifest at all on some systems
1088
- if not whitelist [w ] and not whitelist_regexes [w ].fullmatch ("" ):
1087
+ # This lets us allowlist errors that don't manifest at all on some systems
1088
+ if not allowlist [w ] and not allowlist_regexes [w ].fullmatch ("" ):
1089
1089
exit_code = 1
1090
- print ("note: unused whitelist entry {}" .format (w ))
1090
+ print ("note: unused allowlist entry {}" .format (w ))
1091
1091
1092
- # Print the generated whitelist
1093
- if args .generate_whitelist :
1094
- for e in sorted (generated_whitelist ):
1092
+ # Print the generated allowlist
1093
+ if args .generate_allowlist :
1094
+ for e in sorted (generated_allowlist ):
1095
1095
print (e )
1096
1096
exit_code = 0
1097
1097
@@ -1121,24 +1121,27 @@ def parse_options(args: List[str]) -> argparse.Namespace:
1121
1121
"--check-typeshed" , action = "store_true" , help = "Check all stdlib modules in typeshed"
1122
1122
)
1123
1123
parser .add_argument (
1124
+ "--allowlist" ,
1124
1125
"--whitelist" ,
1125
1126
action = "append" ,
1126
1127
metavar = "FILE" ,
1127
1128
default = [],
1128
1129
help = (
1129
- "Use file as a whitelist . Can be passed multiple times to combine multiple "
1130
- "whitelists. Whitelists can be created with --generate-whitelist "
1130
+ "Use file as an allowlist . Can be passed multiple times to combine multiple "
1131
+ "allowlists. Allowlists can be created with --generate-allowlist "
1131
1132
),
1132
1133
)
1133
1134
parser .add_argument (
1135
+ "--generate-allowlist" ,
1134
1136
"--generate-whitelist" ,
1135
1137
action = "store_true" ,
1136
- help = "Print a whitelist (to stdout) to be used with --whitelist " ,
1138
+ help = "Print an allowlist (to stdout) to be used with --allowlist " ,
1137
1139
)
1138
1140
parser .add_argument (
1141
+ "--ignore-unused-allowlist" ,
1139
1142
"--ignore-unused-whitelist" ,
1140
1143
action = "store_true" ,
1141
- help = "Ignore unused whitelist entries" ,
1144
+ help = "Ignore unused allowlist entries" ,
1142
1145
)
1143
1146
config_group = parser .add_argument_group (
1144
1147
title = 'mypy config file' ,
0 commit comments