[2/6] dts: enable Ruff preview pydoclint rules

Message ID 20241210103253.3931003-3-luca.vizzarro@arm.com (mailing list archive)
State Superseded
Delegated to: Paul Szczepanek
Headers
Series dts: add Ruff and docstring linting |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Luca Vizzarro Dec. 10, 2024, 10:32 a.m. UTC
DTS requires a linter for docstrings but the current selection is
limited. The most promising docstring linter is pydoclint.
On the other hand, Ruff is currently in the process of implementing
pydoclint rules. This would spare the project from supporting yet
another linter, without any loss of benefit.

This commit enables a selection of pydoclint rules in Ruff, which while
still in preview they are already capable of aiding the process.

DOC201 was omitted because it currently does not support one-line
docstrings, trying to enforce full ones even when not needed.

DOC502 was omitted because it complains for exceptions that were
reported but not present in the body of the function. While treating
documented exceptions when they appear to not be raised as an error
is a sound argument, it currently doesn't work well with inherited
class methods, which parent does raise exceptions.

Bugzilla ID: 1455

Signed-off-by: Luca Vizzarro <luca.vizzarro@arm.com>
Reviewed-by: Paul Szczepanek <paul.szczepanek@arm.com>
---
 dts/pyproject.toml | 4 ++++
 1 file changed, 4 insertions(+)
  

Patch

diff --git a/dts/pyproject.toml b/dts/pyproject.toml
index 3436d82116..2658a3d22c 100644
--- a/dts/pyproject.toml
+++ b/dts/pyproject.toml
@@ -65,7 +65,11 @@  select = [
     "D",      # pydocstyle
     "C90",    # mccabe
     "I",      # isort
+    # pydoclint
+    "DOC202", "DOC402", "DOC403", "DOC501"
 ]
+preview = true # enable to get early access to pydoclint rules
+explicit-preview-rules = true # enable ONLY the explicitly selected preview rules
 
 [tool.ruff.lint.pydocstyle]
 convention = "google"