[RFC,v1,2/3] utils: checkstyle.py: Make custom dependency checks possible
diff mbox series

Message ID 20260202112511.640320-3-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • meson: Add `meson.format` file
Related show

Commit Message

Barnabás Pőcze Feb. 2, 2026, 11:25 a.m. UTC
Previously it was only possible check the presence of a dependency,
but no further checks, such as version checks, could be carried out.
Make it possible for any checkers/formatters to specify a custom
function for each dependency that is invoked to carry out extra cheks.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 utils/checkstyle.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart Feb. 5, 2026, 11:35 p.m. UTC | #1
On Mon, Feb 02, 2026 at 12:25:10PM +0100, Barnabás Pőcze wrote:
> Previously it was only possible check the presence of a dependency,

s/check/to check/

> but no further checks, such as version checks, could be carried out.
> Make it possible for any checkers/formatters to specify a custom
> function for each dependency that is invoked to carry out extra cheks.
> 
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  utils/checkstyle.py | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/utils/checkstyle.py b/utils/checkstyle.py
> index fa1355c17..06b9f199a 100755
> --- a/utils/checkstyle.py
> +++ b/utils/checkstyle.py
> @@ -381,12 +381,22 @@ class CheckerBase(metaclass=ClassRegistry):
>  
>          issues = []
>  
> -        for command in cls.dependencies:
> +        for dep in cls.dependencies:
> +            check = None
> +            if type(dep) is str:
> +                command = dep
> +            else:
> +                (command, check) = dep
> +
>              if command not in dependencies:
>                  dependencies[command] = shutil.which(command)
>  
>              if not dependencies[command]:
>                  issues.append(CommitIssue(f'Missing {command} to run {cls.__name__}'))
> +            elif check:
> +                issues_ = check()
> +                if issues_:
> +                    issues.extend(issues_)
>  
>          return issues
>

Patch
diff mbox series

diff --git a/utils/checkstyle.py b/utils/checkstyle.py
index fa1355c17..06b9f199a 100755
--- a/utils/checkstyle.py
+++ b/utils/checkstyle.py
@@ -381,12 +381,22 @@  class CheckerBase(metaclass=ClassRegistry):
 
         issues = []
 
-        for command in cls.dependencies:
+        for dep in cls.dependencies:
+            check = None
+            if type(dep) is str:
+                command = dep
+            else:
+                (command, check) = dep
+
             if command not in dependencies:
                 dependencies[command] = shutil.which(command)
 
             if not dependencies[command]:
                 issues.append(CommitIssue(f'Missing {command} to run {cls.__name__}'))
+            elif check:
+                issues_ = check()
+                if issues_:
+                    issues.extend(issues_)
 
         return issues