DOC003
)This violation code warns you when pydoclint thinks that the docstring
is written in a different style than the style you specified via the
--style
config option.
pydoclint detects the style of a docstring with this very simple procedure:
The authors of pydoclint have manually tested this heuristic in 8 repositories written in all 3 styles (numpy, Google, and Sphinx), and have found this heuristic to be satisfactory:
However, we admit that 8 is too small a sample size to be statistically representative. If you encounter any false positives or false negatives, please don’t hesitate to file an issue here.
Actually, this style mismatch detection feature is by default off.
You can turn this feature on by setting --check-style-mismatch
(or -csm
) to True
(or --check-style-mismatch=True
).
It is not. The authors of pydoclint benchmarked some very large code bases, and here are the results (as of 2025/01/12):
numpy | scikit-learn | Bokeh | Airflow | |
---|---|---|---|---|
Number of .py files | 581 | 929 | 1196 | 5004 |
Run time with 1 style [sec] | 1.84 | 2.68 | 0.77 | 5.50 |
Run time with 3 styles [sec] | 1.91 | 2.79 | 0.78 | 5.77 |
Additional run time [sec] | 0.07 | 0.11 | 0.01 | 0.07 |
Relative additional run time | 4% | 4% | 1% | 5% |
DOC003
: “Docstring style mismatch”.
You are suggested to check if the docstring style is consistent with
what you specified via the --style
config option. If not, please
rewrite your docstring, or specify the correct style via --style
.
Also, please note that specifying an incorrect docstring style may mask other violations. So after you fix the docstring style, you may need to fix other “new” (previously hidden) violations.