DPDK patches and discussions
 help / color / mirror / Atom feed
From: Luca Vizzarro <luca.vizzarro@arm.com>
To: Dean Marx <dmarx@iol.unh.edu>
Cc: probb@iol.unh.edu, yoan.picchi@foss.arm.com,
	 Honnappa.Nagarahalli@arm.com, paul.szczepanek@arm.com,
	dev@dpdk.org
Subject: Re: [PATCH v2] dts: add test case docstring checks to format script
Date: Wed, 27 Aug 2025 16:46:20 +0100	[thread overview]
Message-ID: <6zyctvaihjdlgn3es3z2s3d3ae6ifc33vcqcobhylvz26m7ney@4nzef5s5lxnw> (raw)
In-Reply-To: <20250826200720.104443-1-dmarx@iol.unh.edu>

Hi Dean,

thank you for your patch! Looks mostly good, a couple of comments
though.

On Tue, Aug 26, 2025 at 04:07:20PM +0000, Dean Marx wrote:
> diff --git a/devtools/dts-check-docstrings.py b/devtools/dts-check-docstrings.py
> new file mode 100755
> index 0000000000..0baee6e383
> --- /dev/null
> +++ b/devtools/dts-check-docstrings.py
> @@ -0,0 +1,52 @@

Consider adding a shebang here, like it's already done with the other
scripts.

> +# SPDX-License-Identifier: BSD-3-Clause
> +# Copyright(c) 2025 University of New Hampshire
> +
> +import sys
> +from ast import FunctionDef, Name, walk, get_docstring, parse
> +from pathlib import Path
> +
> +BASE_DIR = Path(__file__).resolve().parent  # dpdk/

The hint is actually wrong, this is dpdk/devtools. I think you meant to
make this:

    BASE_DIR = Path(__file__).resolve().parent.parent

> +TESTS_DIR = BASE_DIR.parent / "dts" / "tests"  # dts/tests/

and this would just be:

    TESTS_DIR = BASE_DIR / "dts" / "tests"

> +
> +
> +def has_test_decorator(node: FunctionDef) -> bool:
> +    """Return True if function has @func_test or @perf_test decorator."""
> +    for decorator in node.decorator_list:
> +        if isinstance(decorator, Name) and decorator.id in {"func_test", "perf_test"}:

I wouldn't hard code the decorator names like this. Put this in a
constant at the top instead:

    DECORATOR_NAMES = {"func_test", "perf_test"}

> +            return True
> +    return False
<snip>
> diff --git a/devtools/dts-check-format.sh b/devtools/dts-check-format.sh
> index 907eed1293..da6e6f34ee 100755
> --- a/devtools/dts-check-format.sh
> +++ b/devtools/dts-check-format.sh
> @@ -86,7 +86,14 @@ if $lint; then
>  		ruff check --fix
>  		errors=$((errors + $?))
>  
> +		docstring_script_path=$(dirname "$0")
> +		docstring_script_path=$(cd "$docstring_script_path" && pwd)
> +		docstring_script="$docstring_script_path/dts-check-docstrings.py"
> +		python "$docstring_script"
> +		errors=$((errors + $?))
> +

I wouldn't insert this with the ruff if scope. This can still stay under
the lint if block, but give it its own.

>  		git update-index --refresh
> +

Best regards,
Luca

      reply	other threads:[~2025-08-27 15:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-20 19:38 [PATCH v1] " Dean Marx
2025-08-26 20:07 ` [PATCH v2] " Dean Marx
2025-08-27 15:46   ` Luca Vizzarro [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6zyctvaihjdlgn3es3z2s3d3ae6ifc33vcqcobhylvz26m7ney@4nzef5s5lxnw \
    --to=luca.vizzarro@arm.com \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=dev@dpdk.org \
    --cc=dmarx@iol.unh.edu \
    --cc=paul.szczepanek@arm.com \
    --cc=probb@iol.unh.edu \
    --cc=yoan.picchi@foss.arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).