@@ -176,6 +176,11 @@ def _ignore_issue(self, node: ast.AST, check: str) -> bool:
176
176
if check not in self .config ["checks" ]:
177
177
return True
178
178
179
+ if self .config ["exclude" ] and re .search (
180
+ self .config ["exclude" ], "." .join (self .stack )
181
+ ):
182
+ return True
183
+
179
184
if self .config ["overrides" ]:
180
185
try :
181
186
if check == "GL08" :
@@ -262,7 +267,7 @@ def parse_config(dir_path: os.PathLike = None) -> dict:
262
267
dict
263
268
Config options for the numpydoc validation hook.
264
269
"""
265
- options = {"checks" : {"all" }, "overrides" : {}}
270
+ options = {"checks" : {"all" }, "exclude" : set (), " overrides" : {}}
266
271
dir_path = Path (dir_path ).expanduser ().resolve ()
267
272
268
273
toml_path = dir_path / "pyproject.toml"
@@ -273,6 +278,7 @@ def parse_config(dir_path: os.PathLike = None) -> dict:
273
278
pyproject_toml = tomllib .load (toml_file )
274
279
config = pyproject_toml .get ("tool" , {}).get ("numpydoc_validation" , {})
275
280
options ["checks" ] = set (config .get ("checks" , options ["checks" ]))
281
+ options ["exclude" ] = set (config .get ("exclude" , options ["exclude" ]))
276
282
for check in ["SS05" , "GL08" ]:
277
283
regex = config .get (f"override_{ check } " )
278
284
if regex :
@@ -284,11 +290,22 @@ def parse_config(dir_path: os.PathLike = None) -> dict:
284
290
try :
285
291
try :
286
292
options ["checks" ] = set (
287
- config .get (numpydoc_validation_config_section , "checks" ).split ("," )
293
+ config .get (numpydoc_validation_config_section , "checks" )
294
+ .rstrip ("," )
295
+ .split ("," )
288
296
or options ["checks" ]
289
297
)
290
298
except configparser .NoOptionError :
291
299
pass
300
+ try :
301
+ options ["exclude" ] = set (
302
+ config .get (numpydoc_validation_config_section , "exclude" )
303
+ .rstrip ("," )
304
+ .split ("," )
305
+ or options ["exclude" ]
306
+ )
307
+ except configparser .NoOptionError :
308
+ pass
292
309
try :
293
310
options ["overrides" ]["SS05" ] = re .compile (
294
311
config .get (numpydoc_validation_config_section , "override_SS05" )
@@ -305,6 +322,11 @@ def parse_config(dir_path: os.PathLike = None) -> dict:
305
322
pass
306
323
307
324
options ["checks" ] = get_validation_checks (options ["checks" ])
325
+ options ["exclude" ] = (
326
+ re .compile (r"|" .join (exp for exp in options ["exclude" ]))
327
+ if options ["exclude" ]
328
+ else None
329
+ )
308
330
return options
309
331
310
332
0 commit comments