-
Notifications
You must be signed in to change notification settings - Fork 16
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
DOC503 false positive when same exception class is documented multiple times #171
Comments
What makes it worse is that my attempts to add |
hey @ssbarnea I actually chose to write the doc503 check this way. not a bug but I am open to discussion. when I wrote the check I couldn't find any docstring style guideline that discussed the possibility of specifying the exception multiple times (eg https://google.github.io/styleguide/pyguide.html#doc-function-raises ) - please link if you find any because I ended up having to make this opinionated choice: if an exception is raised for different reasons, I figured it would be more clear to refactor to raise different exceptions, one for each reason. it may be a bug that flake8 noqa comment doesn't work though, I'll look into that. |
Hi @ssbarnea , I think |
I'm also leaning towards the current implementation (i.e., merging duplicated exceptions in the docstring). For example, if a certain exception is raised for different reasons, we can write the docstring like this:
Also, Python's "raises" section in docstrings remind me a bit of Java's "throws" section in the signature: void doSomething() throws ArithmeticException, ArrayIndexOutOfBoundsException {
// do something
} Each exception is also only mentioned once in the signature. That said, if there are other style guides that is in favor of not merging exceptions, we can consider making this a configurable behavior. |
Given our discussion above, I'm closing this issue. If anyone has more comments to share, please feel free to comment below. And we can reopen it (or create a separate issue) if needed. |
Apparently, people's opinion shifts over time, as does mine. I'm open to adding an option to let users choose whether to deduplicate exceptions. See more details here: #193 (comment) There will be a PR soon by @s-weigand and/or myself. |
And the docstring looks like
To be honest, I do not see anything wrong with docstring and having to rewrite it to workaround the linting error might make the text much harder to read.
I suppose that removing duplicates before checking should address this issue.
The text was updated successfully, but these errors were encountered: