-
Notifications
You must be signed in to change notification settings - Fork 8
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
False positive for RST213 and RST210 from *arg and **kwargs #18
Comments
That does seem to be a conflict - https://www.sphinx-doc.org/en/master/usage/extensions/example_numpy.html#example-numpy and https://www.sphinx-doc.org/en/master/usage/extensions/example_google.html agree, but to me they look malformed. Perhaps the extension special cases it? If so, we could do the same in RST210 and whatever unique code I should give for strong (since RST299 is a place holder). |
Sorry, I didn't quite get the "special cases" part. What do you suggest? |
The following is clearly wrong in RST:
Yet the extensions seem to recommend this:
Perhaps the extension does something special with these two words? Also, I see I am missing a bunch of related messages like:
See: https://sourceforge.net/p/docutils/code/HEAD/tree/trunk/docutils/docutils/parsers/rst/states.py |
Oh, I see. The notation of |
Yes, the following are fine - escaping with slashes, or wrapping with back-ticks:
Perhaps it is worth opening an issue with the docstring extension to double check their intent. |
These are all examples fitting the pattern: 'Inline %s start-string without end-string.' Raised in docutils/parsers/rst/states.py Noted in passing on GitHub issue #18.
I've released v0.0.12, so now instead of RST299 (ending 99 indicating a previously unseen error), you should get RST213. |
I've recently tried the plugin on two large projects with lots of these false positives: rigetti/pyquil#1141 Do you think it should ignore Or, should there be configurable lists of variable names to ignore (since not all projects will use these exact conventions)? |
Yes, |
I don't see an easy way to fix this (a docutils expert might), but have a hack on PR #27 which might be worth testing? |
Hey, I stumbled over this, too and I think its worth mentioning that sphinx.ext.napoleon seems to auto-escape asterisks at the beginning of each argument. See https://github.com/sphinx-doc/sphinx/blob/3.x/sphinx/ext/napoleon/docstring.py#L326
You can actually find both notations in there. The asterisks are escaped everywhere except in the Considering this, I think it would be perfectly fine to treat them as special cases just like the napoleon extension does. |
Thanks for the pointer to the napoleon special casing code - I agree, it would be practical to follow their example. |
I did update the README to suggest the following configuration if using the Google style:
This is still not ideal from a usability point of view. Actually applying the napoleon transformation does seem the like best approach, but it adds complexity. |
I added * in the end of *args ... *. It helps. |
This code produces two violations:
Output:
That's because
flake8-rst-docstrings
is unhappy about*args
and**kwargs
in the docs. But,napoleon
andgoogle
explicitly says to write them like so, proof: https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html#example-googleSo, I guess that these two rules should respect this case.
The text was updated successfully, but these errors were encountered: