Skip to content
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

How to specify numpydoc_validation_checks from CLI #459

Open
HealthyPear opened this issue Jun 7, 2023 · 4 comments
Open

How to specify numpydoc_validation_checks from CLI #459

HealthyPear opened this issue Jun 7, 2023 · 4 comments

Comments

@HealthyPear
Copy link

From the docs it is not clear if this is possible and my first tries failed.

If I do python -m numpydoc -hI see,

Implementing `python -m numpydoc` functionality.

positional arguments:
  import_path           e.g. numpy.ndarray

options:
  -h, --help            show this help message and exit
  -c CONFIG, --config CONFIG
                        key=val where val will be parsed by literal_eval, e.g. -c use_plots=True. Multiple -c can be used.
  --validate            validate the object and report errors

and from the docs I see e.g. the numpydoc_use_plots configuration option mentioned in the help example.

I would like to specify the equivalent of e.g. numpydoc_validation_checks = {"all", "GL01", "GL02", "GL05"} - is this possible?

If not it should be explained, if yes I think there should be more examples of usage.

I tried e.g.,

python -m numpydoc -c numpydoc_validation_checks=all -c numpydoc_validation_checks=GL01 -c numpydoc_validation_checks=GL02 -c numpydoc_validation_checks=GL05 --validate test_module.good_docstring

and

python -m numpydoc -c numpydoc_validation_checks{"all", "GL01", "GL02", "GL05"} --validate test_module.good_docstring

@echedey-ls
Copy link

The problem here is that no config is being passed onto the validator when --validate is called.
See this line in __main__.py.

@HealthyPear
Copy link
Author

Oh ok if so it seems an easy fix, I can try and make a PR if you want

@echedey-ls
Copy link

I don't maintain this project, but I'm looking into how to do something similar. You'll find that the function validate does not have arguments of which rules to exclude/include. I will stop working on this for now, but I would look into how sphinx is filtering the output, in case you want to continue.

@rossbar
Copy link
Contributor

rossbar commented Jul 8, 2023

See also #467 - there is indeed a difference in the (now) 3 interfaces to the validation functionality (cli, pre-commit, and sphinx-build). #476 should help, but there will still be room for improvement. Ultimately I think there's an opportunity to refactor the validation to make it more modular - one of the big disadvantages currently is that all the validation checks run regardless of configuration - the configuration just dictates what's reported.

@stefmolin stefmolin mentioned this issue Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants