File tree Expand file tree Collapse file tree 2 files changed +45
-11
lines changed Expand file tree Collapse file tree 2 files changed +45
-11
lines changed Original file line number Diff line number Diff line change 34
34
raise RuntimeError ("Sphinx 5 or newer is required" )
35
35
36
36
from .docscrape_sphinx import get_doc_object
37
+ from .utils import get_validation_checks
37
38
from .validate import validate , ERROR_MSGS
38
39
from .xref import DEFAULT_LINKS
39
40
from . import __version__
@@ -310,17 +311,9 @@ def update_config(app, config=None):
310
311
311
312
# Processing to determine whether numpydoc_validation_checks is treated
312
313
# as a blocklist or allowlist
313
- valid_error_codes = set (ERROR_MSGS .keys ())
314
- if "all" in config .numpydoc_validation_checks :
315
- block = deepcopy (config .numpydoc_validation_checks )
316
- config .numpydoc_validation_checks = valid_error_codes - block
317
- # Ensure that the validation check set contains only valid error codes
318
- invalid_error_codes = config .numpydoc_validation_checks - valid_error_codes
319
- if invalid_error_codes :
320
- raise ValueError (
321
- f"Unrecognized validation code(s) in numpydoc_validation_checks "
322
- f"config value: { invalid_error_codes } "
323
- )
314
+ config .numpydoc_validation_checks = get_validation_checks (
315
+ config .numpydoc_validation_checks
316
+ )
324
317
325
318
# Generate the regexp for docstrings to ignore during validation
326
319
if isinstance (config .numpydoc_validation_exclude , str ):
Original file line number Diff line number Diff line change
1
+ """Utility functions for numpydoc."""
2
+
3
+ from copy import deepcopy
4
+ from typing import Set
5
+
6
+ from .validate import ERROR_MSGS
7
+
8
+
9
+ def get_validation_checks (validation_checks : Set [str ]) -> Set [str ]:
10
+ """
11
+ Get the set of validation checks to report on.
12
+
13
+ Parameters
14
+ ----------
15
+ validation_checks : set[str]
16
+ A set of validation checks to report on. If the set is ``{"all"}``,
17
+ all checks will be reported. If the set contains just specific checks,
18
+ only those will be reported on. If the set contains both ``"all"`` and
19
+ specific checks, all checks except those included in the set will be
20
+ reported on.
21
+
22
+ Returns
23
+ -------
24
+ set[str]
25
+ The set of validation checks to report on.
26
+ """
27
+ # TODO: add tests
28
+ valid_error_codes = set (ERROR_MSGS .keys ())
29
+ if "all" in validation_checks :
30
+ block = deepcopy (validation_checks )
31
+ validation_checks = valid_error_codes - block
32
+
33
+ # Ensure that the validation check set contains only valid error codes
34
+ invalid_error_codes = validation_checks - valid_error_codes
35
+ if invalid_error_codes :
36
+ raise ValueError (
37
+ f"Unrecognized validation code(s) in numpydoc_validation_checks "
38
+ f"config value: { invalid_error_codes } "
39
+ )
40
+
41
+ return validation_checks
You can’t perform that action at this time.
0 commit comments