Skip to content

Commit 4a6c2ec

Browse files
committed
Deprecate override_GL08 since global exclusion covers this.
1 parent 8a88bda commit 4a6c2ec

File tree

2 files changed

+12
-20
lines changed

2 files changed

+12
-20
lines changed

numpydoc/hooks/validate_docstrings.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,6 @@ def _ignore_issue(self, node: ast.AST, check: str) -> bool:
182182
return True
183183

184184
if self.config["overrides"]:
185-
try:
186-
if check == "GL08":
187-
pattern = self.config["overrides"].get("GL08")
188-
if pattern and re.match(pattern, node.name):
189-
return True
190-
except AttributeError: # ast.Module nodes don't have a name
191-
pass
192-
193185
if check == "SS05":
194186
pattern = self.config["overrides"].get("SS05")
195187
if pattern and re.match(pattern, ast.get_docstring(node)) is not None:
@@ -278,8 +270,15 @@ def parse_config(dir_path: os.PathLike = None) -> dict:
278270
pyproject_toml = tomllib.load(toml_file)
279271
config = pyproject_toml.get("tool", {}).get("numpydoc_validation", {})
280272
options["checks"] = set(config.get("checks", options["checks"]))
281-
options["exclude"] = set(config.get("exclude", options["exclude"]))
282-
for check in ["SS05", "GL08"]:
273+
274+
global_exclusions = config.get("exclude", options["exclude"])
275+
options["exclude"] = set(
276+
global_exclusions
277+
if isinstance(global_exclusions, list)
278+
else [global_exclusions]
279+
)
280+
281+
for check in ["SS05"]:
283282
regex = config.get(f"override_{check}")
284283
if regex:
285284
options["overrides"][check] = re.compile(regex)
@@ -312,12 +311,6 @@ def parse_config(dir_path: os.PathLike = None) -> dict:
312311
)
313312
except configparser.NoOptionError:
314313
pass
315-
try:
316-
options["overrides"]["GL08"] = re.compile(
317-
config.get(numpydoc_validation_config_section, "override_GL08")
318-
)
319-
except configparser.NoOptionError:
320-
pass
321314
except configparser.NoSectionError:
322315
pass
323316

numpydoc/tests/hooks/test_validate_hook.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def test_validate_hook_with_toml_config(example_module, tmp_path, capsys):
132132
"ES01",
133133
]
134134
override_SS05 = '^((Process|Assess|Access) )'
135-
override_GL08 = '^(__init__)$'
135+
exclude = '\\.__init__$'
136136
"""
137137
)
138138
)
@@ -170,8 +170,8 @@ def test_validate_hook_with_setup_cfg(example_module, tmp_path, capsys):
170170
"""
171171
[tool:numpydoc_validation]
172172
checks = all,EX01,SA01,ES01
173+
exclude = \\.__init__$
173174
override_SS05 = ^((Process|Assess|Access) )
174-
override_GL08 = ^(__init__)$
175175
"""
176176
)
177177
)
@@ -265,8 +265,7 @@ def test_validate_hook_exclude_option_setup_cfg(example_module, tmp_path, capsys
265265
[tool:numpydoc_validation]
266266
checks = all,EX01,SA01,ES01
267267
override_SS05 = ^((Process|Assess|Access) )
268-
override_GL08 = ^(__init__)$
269-
exclude = \\.NewClass$,
268+
exclude = \\.NewClass$,\\.__init__$
270269
"""
271270
)
272271
)

0 commit comments

Comments
 (0)