-
Notifications
You must be signed in to change notification settings - Fork 18
False positive DOC503 in 0.5.12 #193
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
Hi @Waschenbacher , this is not a bug, but a feature. Please see the code here: pydoclint/pydoclint/utils/return_yield_raise.py Lines 98 to 100 in dfd9494
We deduplicated and sorted the exceptions within a function. The reason is that very often we have functions with many exceptions (e.g., 5 TypeErrors, 3 ValueErrors, 2 IOErrors, ...), so it's not very practical to list every raised exception in the correct order in the docstring. (Note: if you don't want deduplication, the only sensible for a linter is to enforce the order.) It's not difficult to add another config option to suppress deduplication, but the key question is whether we should add such an option. My current position is no, unless there are very compelling reasons. |
Hi @jsh9 |
I just stumbled on the same thing (also 2 My reasoning (hopefully compelling) is simply how it renders in sphinx. My naive approach to fix the linter issue was to just However While one can consider having multiple errors of the same type a bad thing for handling them up the line, there are also quite a few cases where you do not want to handle errors but let it error out and still give users a fine grain actionable error message, without the need to create a subclass for each error reason. |
Hi @s-weigand , if you'd want to make a code change, you are welcome to do so. Thanks! I think the scope of this proposed config option is limited enough that it won't affect other existing functionalities. So if it benefits some users, let's add it. (And the default value of this option can be "off" to maintain backward compatibility.) But just note that if we do add this option, we'd need to update the documentation to explain how to write the "raises" section if turn this option on -- specifically, how shall we order the exceptions in the docstring: in the order of appearance in the function/method, or in alphabetical order? |
My pragmatic solution would be to use alphabetical order on both sides and ignore the order. One way around this design decision would be to give the user the ability to configure and enforce the style they prefer. --suppress-exception-deduplication
"off" | "unordered" | "occurrence" | "alphabetical" (default "off") |
False positive
DOC503
error in version0.5.12
?------------------------Bug report---------------------
[Example]:
[To reproduce]
Running
pydoclint --style=google --check-return-types=False .
on terminal in a conda env (Env details see below) gives the pydoclint error message below.[pydoclint error message]
DOC503: Function
check_positive
exceptions in the "Raises" section in the docstring do not match those in the function body Raises values in the docstring: ['ValueError', 'ValueError']. Raised exceptions in the body: ['ValueError'].[Expected output]
[Environment]
------------------------Good example---------------------
My guess: It seems that the false alarm on DOC503 occurs only when there are multiple errors of the same type. For errors of different types (see the example below), no pydoclint complaints.
[Example]:
[Output]:
[Other details]:
All other details are the same as in the bug-example.
The text was updated successfully, but these errors were encountered: