Open JohannesBuchner opened 3 weeks ago
Hi, you'd need to annotate the return types in the function signature.
def list_documented_parameters(docstring: str) -> tuple[list, list, list]:
My code base actually does not have any annotations. I added one to the param arg to make the case simpler, but this error occurs with or without.
There is --arg-type-hints-in-signature=False
but nothing corresponding for return types.
If I may make a suggestion, the error code should be split into two:
This would allow me to ignore case (1), and give error messages that are precise.
A further possibility to consider is to change the code so that DOC203 is not raised when --arg-type-hints-in-signature=False
.
one error code for "missing annotations".
pydoclint doesn't check "missing annotations" but rather inconsistent annotations. For example, if annotations are missing in the function signature and in the docstring, pydoclint is fine with that.
A further possibility to consider is to change the code so that DOC203 is not raised when --arg-type-hints-in-signature=False.
So in your example, return type annotation rather than argument type annotation missing. "arg type hints in signature" only covers the arg list, not the return type.
one error code for "missing annotations".
pydoclint doesn't check "missing annotations" but rather inconsistent annotations. For example, if annotations are missing in the function signature and in the docstring, pydoclint is fine with that.
I agree that this should be the behaviour.
A further possibility to consider is to change the code so that DOC203 is not raised when --arg-type-hints-in-signature=False.
So in your example, return type annotation rather than argument type annotation missing. "arg type hints in signature" only covers the arg list, not the return type.
Yes, it only refers to the arg list. Perhaps an additional flag is needed then.
I am maintaining a code base that should work with old python versions, I cannot add annotations but would like to keep the informative docstring annotations. In my mind, unspecified annotations (that is, a lack of PEP 3107 annotations) are consistent and compatible with documented annotations.
You can use the config option check-return-types
to opt out of checking return types: https://jsh9.github.io/pydoclint/config_options.html#10---check-return-types-shortform--crt-default-true
Also, if you are dealing with a legacy code base, you can also use the "baseline" feature: https://jsh9.github.io/pydoclint/config_options.html#17---baseline
The following code I believe follows numpydoc style for the return documentation:
pydoclint gives: "1: DOC203: Function
list_documented_parameters
return type(s) in docstring not consistent with the return annotation. Return annotation has 0 type(s); docstring return section has 3 type(s)."Sorry if I misunderstood something.
Version: