File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -300,9 +300,17 @@ def update_config(app, config=None):
300
300
301
301
# Processing to determine whether numpydoc_validation_checks is treated
302
302
# as a blocklist or allowlist
303
+ valid_error_codes = set (ERROR_MSGS .keys ())
303
304
if "all" in config .numpydoc_validation_checks :
304
305
block = deepcopy (config .numpydoc_validation_checks )
305
- config .numpydoc_validation_checks = set (ERROR_MSGS .keys ()) - block
306
+ config .numpydoc_validation_checks = valid_error_codes - block
307
+ # Ensure that the validation check set contains only valid error codes
308
+ invalid_error_codes = config .numpydoc_validation_checks - valid_error_codes
309
+ if invalid_error_codes :
310
+ raise ValueError (
311
+ f"Unrecognized validation code(s) in numpydoc_validation_checks "
312
+ f"config value: { invalid_error_codes } "
313
+ )
306
314
307
315
308
316
# ------------------------------------------------------------------------------
Original file line number Diff line number Diff line change 2
2
import pytest
3
3
from io import StringIO
4
4
from copy import deepcopy
5
- from numpydoc .numpydoc import mangle_docstrings , _clean_text_signature
5
+ from numpydoc .numpydoc import (
6
+ mangle_docstrings , _clean_text_signature , update_config
7
+ )
6
8
from numpydoc .xref import DEFAULT_LINKS
7
9
from sphinx .ext .autodoc import ALL
8
10
from sphinx .util import logging
@@ -151,6 +153,14 @@ def test_mangle_docstring_validation_warnings(
151
153
assert w not in warnings
152
154
153
155
156
+ def test_update_config_invalid_validation_set ():
157
+ app = MockApp ()
158
+ # Results in {'a', 'l'} instead of {"all"}
159
+ app .config .numpydoc_validation_checks = set ("all" )
160
+ with pytest .raises (ValueError , match = "Unrecognized validation code" ):
161
+ update_config (app )
162
+
163
+
154
164
if __name__ == "__main__" :
155
165
import pytest
156
166
pytest .main ()
You can’t perform that action at this time.
0 commit comments