-
-
Notifications
You must be signed in to change notification settings - Fork 173
Make numpydoc lint --ignore ... parsing more robust
#560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
29abec9
30de526
7506e1a
8c65282
3236347
c790eeb
bb087e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |||||||||||||||||
|
|
||||||||||||||||||
| import argparse | ||||||||||||||||||
| import ast | ||||||||||||||||||
| import re | ||||||||||||||||||
| from collections.abc import Sequence | ||||||||||||||||||
| from pathlib import Path | ||||||||||||||||||
| from typing import List | ||||||||||||||||||
|
|
@@ -100,17 +101,19 @@ def _parse_config(s): | |||||||||||||||||
| ) | ||||||||||||||||||
| lint_parser.add_argument( | ||||||||||||||||||
| "--ignore", | ||||||||||||||||||
| type=str, | ||||||||||||||||||
| nargs="*", | ||||||||||||||||||
| help=( | ||||||||||||||||||
| f"""Check codes to ignore.{ | ||||||||||||||||||
| "Check codes to ignore. Can be specified multiple times; each value\n" | ||||||||||||||||||
| "may contain multiple comma or space separated codes\n" | ||||||||||||||||||
| "(e.g., --ignore ES01,SA01 or --ignore ES01 --ignore 'SA01 EX01')." | ||||||||||||||||||
| f"""{ | ||||||||||||||||||
| " Currently ignoring the following from " | ||||||||||||||||||
| f"{Path(project_root_from_cwd) / config_file}: {ignored_checks_text}" | ||||||||||||||||||
| "Values provided here will be in addition to the above, unless an alternate config is provided." | ||||||||||||||||||
| if ignored_checks | ||||||||||||||||||
| else "" | ||||||||||||||||||
| }""" | ||||||||||||||||||
| ), | ||||||||||||||||||
| action="append", | ||||||||||||||||||
| ) | ||||||||||||||||||
| lint_parser.set_defaults(func=validate_docstrings.run_hook) | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
@@ -123,6 +126,13 @@ def main(argv: Sequence[str] | None = None) -> int: | |||||||||||||||||
|
|
||||||||||||||||||
| args = vars(ap.parse_args(argv)) | ||||||||||||||||||
|
|
||||||||||||||||||
| # Parse --ignored=SA01,EX01 | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo:
Suggested change
|
||||||||||||||||||
| ignored_checks = [] | ||||||||||||||||||
| if args.get("ignore", None) is not None: | ||||||||||||||||||
| for checks in args["ignore"]: | ||||||||||||||||||
|
Comment on lines
+131
to
+132
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I prefer the walrus operator if I am going to use the value (also removing the
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm also wondering if we even need the
Suggested change
|
||||||||||||||||||
| ignored_checks += re.split("\\W+", checks) | ||||||||||||||||||
| args["ignore"] = ignored_checks | ||||||||||||||||||
|
|
||||||||||||||||||
| try: | ||||||||||||||||||
| func = args.pop("func") | ||||||||||||||||||
| return func(**args) | ||||||||||||||||||
|
|
||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.