20
20
21
21
from .. import docscrape , validate
22
22
from .utils import find_project_root
23
+ from ..utils import get_validation_checks
23
24
24
25
25
26
# inline comments that can suppress individual checks per line
@@ -172,7 +173,7 @@ def _ignore_issue(self, node: ast.AST, check: str) -> bool:
172
173
bool
173
174
Whether the issue should be exluded from the report.
174
175
"""
175
- if check in self .config ["exclusions " ]:
176
+ if check not in self .config ["checks " ]:
176
177
return True
177
178
178
179
if self .config ["overrides" ]:
@@ -261,7 +262,7 @@ def parse_config(dir_path: os.PathLike = None) -> dict:
261
262
dict
262
263
Config options for the numpydoc validation hook.
263
264
"""
264
- options = {"exclusions " : [] , "overrides" : {}}
265
+ options = {"checks " : { "all" } , "overrides" : {}}
265
266
dir_path = Path (dir_path ).expanduser ().resolve ()
266
267
267
268
toml_path = dir_path / "pyproject.toml"
@@ -271,7 +272,7 @@ def parse_config(dir_path: os.PathLike = None) -> dict:
271
272
with open (toml_path , "rb" ) as toml_file :
272
273
pyproject_toml = tomllib .load (toml_file )
273
274
config = pyproject_toml .get ("tool" , {}).get ("numpydoc_validation" , {})
274
- options ["exclusions " ] = config .get ("ignore " , [] )
275
+ options ["checks " ] = set ( config .get ("checks " , options [ "checks" ]) )
275
276
for check in ["SS05" , "GL08" ]:
276
277
regex = config .get (f"override_{ check } " )
277
278
if regex :
@@ -282,9 +283,10 @@ def parse_config(dir_path: os.PathLike = None) -> dict:
282
283
numpydoc_validation_config_section = "tool:numpydoc_validation"
283
284
try :
284
285
try :
285
- options ["exclusions" ] = config .get (
286
- numpydoc_validation_config_section , "ignore"
287
- ).split ("," )
286
+ options ["checks" ] = set (
287
+ config .get (numpydoc_validation_config_section , "checks" ).split ("," )
288
+ or options ["checks" ]
289
+ )
288
290
except configparser .NoOptionError :
289
291
pass
290
292
try :
@@ -302,6 +304,7 @@ def parse_config(dir_path: os.PathLike = None) -> dict:
302
304
except configparser .NoSectionError :
303
305
pass
304
306
307
+ options ["checks" ] = get_validation_checks (options ["checks" ])
305
308
return options
306
309
307
310
@@ -357,7 +360,7 @@ def main(argv: Union[Sequence[str], None] = None) -> int:
357
360
+ "\n " .join (
358
361
[
359
362
f"- { check } : { validate .ERROR_MSGS [check ]} "
360
- for check in config_options ["exclusions " ]
363
+ for check in set ( validate . ERROR_MSGS . keys ()) - config_options ["checks " ]
361
364
]
362
365
)
363
366
+ "\n "
@@ -391,15 +394,15 @@ def main(argv: Union[Sequence[str], None] = None) -> int:
391
394
' Currently ignoring the following from '
392
395
f'{ Path (project_root_from_cwd ) / config_file } : { ignored_checks } '
393
396
'Values provided here will be in addition to the above, unless an alternate config is provided.'
394
- if config_options ["exclusions " ] else ''
397
+ if config_options ["checks " ] else ''
395
398
} """
396
399
),
397
400
)
398
401
399
402
args = parser .parse_args (argv )
400
403
project_root , _ = find_project_root (args .files )
401
404
config_options = parse_config (args .config or project_root )
402
- config_options ["exclusions" ]. extend (args .ignore or [])
405
+ config_options ["checks" ] -= set (args .ignore or [])
403
406
404
407
findings = []
405
408
for file in args .files :
0 commit comments