-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
W9006: missing-raises-doc false positive #1502
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
Comments
@AWhetter this seems right up your alley |
This is raising an error because Google docstrings don't require you to specify the linking, it will link for you. |
Not sure if it is the expected behaviour, your example worked but for that I had to raise the exact exception I am mentioning in the raises section. Example: from marshmallow import ValidationError
def some_method():
"""summary string.
Raises:
~marshmallow.exceptions.ValidationError: reason, why being raised.
"""
raise ValidationError('message string') does not work while the following works: import marshmallow
def some_method():
"""summary string.
Raises:
~marshmallow.exceptions.ValidationError: reason, why being raised.
"""
raise marshmallow.exceptions.ValidationError('message string')
# or raise marshmallow.ValidationError('message string') |
This definitely isn't expected behaviour! I'll take a look. |
I can't reproduce with the latest pylint and astroid, both on master. Please could you confirm? |
@anuragagarwal561994 We're you able to test this with the latest pylint? |
The problem still exists
script.py """Some Module"""
from marshmallow import ValidationError
# or from marshmallow.exceptions import ValidationError also doesn't work
# from marshmallow import exceptions and then use exceptions.ValidationError works
def some_method():
"""summary string.
Raises:
~marshmallow.exceptions.ValidationError: reason, why being raised.
"""
raise ValidationError('message string')
.pylintrc
result
|
To any new contributors looking to solve this issue; docparams currently does a simple set difference between the name of the exceptions in the code and the names of the exceptions in the docstring (https://github.com/PyCQA/pylint/blob/1c0356f0683901e6e3561f4caeb176ff3e20be1e/pylint/extensions/docparams.py#L216). It does not attempt to do any kind of name resolution. This process will need to be made more intelligent, either by attempting to fully resolve where the exception comes from or at least by doing something like a |
Can anyone provide the specification for what text should be supported in the 'Raises' clause to refer to the exception type? I'm specifically wondering if the leading ~ in the above examples is valid, and whether there's other syntax other than just the exception name that should supported. For context, pylint currently has a couple of issues preventing this example from working:
I understand #1 and #2, but I'm not sure what to update the regexp for in #3, hence my initial question. I found the use of '~' as part of a cross-reference syntax for sphinx documented here: http://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html#cross-referencing-syntax Finally, here's a quick repro. Given the following input:
Here's the command to show the error:
|
Thanks for the detailed report @jrobertson98atx
|
I've submitted PR#2656 to take care of issues #1 and #2. Let me know if it makes sense. Regarding the regexp: I'm not sure what is and isn't permissible here, so I didn't want to update it for this PR. It sounds like the leading '~' is ok. Is there more than needs to be updated? For reference, the following are all valid sphinx references for exception and I'm wondering if they should all be supported:
|
Yes a leading |
Thanks for the clarification. Adding support for ~ and ! should be
straightforward.
Do you have a reference to the original Google style guide that includes
'~'? I'm not seeing it in the top google searches for "google python style
guide".
…On Wed, Dec 19, 2018 at 3:53 AM Ashley Whetter ***@***.***> wrote:
Yes a leading ~ is ok. A leading ! is fine also.
Not allowing :exc: and other roles is intentional. It's an opinionated
decision because Sphinx accepts them (the original Google style guide
doesn't), but it's less readable than the plain type, and Google docstrings
are all about readability.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1502 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ArT13fsA4Rdqe2SQZjNBpsmnCRw72gTGks5u6gytgaJpZM4NnjB2>
.
|
Updated checking of missing Raises to check exceptions that have absolute paths. Added W9006 testcases for google, numpy, and sphinx Close #1502
Updated checking of missing Raises to check exceptions that have absolute paths. Close #1502
For context see #1502 (comment) In this issue it was agreed that `re.error`, `~re.error` and `!re.error` would all be accepted. However, it's also common in Sphinx to use a `.` prefix for local references.
Steps to reproduce
Raises
section.Current behavior
Gives false positive.
Expected behavior
It should be able to realise internal, external linking.
pylint --version output
1.7.1
The text was updated successfully, but these errors were encountered: