@@ -81,6 +81,20 @@ def validate_codes(codes: list[str]) -> list[str]:
8181 return codes
8282
8383
84+ def validate_package_allow_list (allow_list : list [str ]) -> list [str ]:
85+ for p in allow_list :
86+ msg = f"Invalid allow list entry: { p } "
87+ if "*" in p :
88+ raise argparse .ArgumentTypeError (
89+ f"{ msg } (entries are already prefixes so must not contain *)"
90+ )
91+ if "\\ " in p or "/" in p :
92+ raise argparse .ArgumentTypeError (
93+ f"{ msg } (entries must be packages like foo.bar not directories or files)"
94+ )
95+ return allow_list
96+
97+
8498def expand_path (path : str ) -> str :
8599 """Expand the user home directory and any environment variables contained within
86100 the provided path.
@@ -164,6 +178,9 @@ def split_commas(value: str) -> list[str]:
164178 "plugins" : lambda s : [p .strip () for p in split_commas (s )],
165179 "always_true" : lambda s : [p .strip () for p in split_commas (s )],
166180 "always_false" : lambda s : [p .strip () for p in split_commas (s )],
181+ "untyped_call_exception" : lambda s : validate_package_allow_list (
182+ [p .strip () for p in split_commas (s )]
183+ ),
167184 "enable_incomplete_feature" : lambda s : [p .strip () for p in split_commas (s )],
168185 "disable_error_code" : lambda s : validate_codes ([p .strip () for p in split_commas (s )]),
169186 "enable_error_code" : lambda s : validate_codes ([p .strip () for p in split_commas (s )]),
@@ -187,6 +204,7 @@ def split_commas(value: str) -> list[str]:
187204 "plugins" : try_split ,
188205 "always_true" : try_split ,
189206 "always_false" : try_split ,
207+ "untyped_call_exception" : lambda s : validate_package_allow_list (try_split (s )),
190208 "enable_incomplete_feature" : try_split ,
191209 "disable_error_code" : lambda s : validate_codes (try_split (s )),
192210 "enable_error_code" : lambda s : validate_codes (try_split (s )),
0 commit comments