From 75caac6fe0b9930b64df981f37aa011e85632202 Mon Sep 17 00:00:00 2001 From: Tim Laurence Date: Fri, 5 Aug 2022 21:05:51 +0000 Subject: [PATCH] pw_presubmit: Add ability to inject CodeFormats into presubmit_checks Change-Id: Id3111180e957efd42fd7246d09b9d237fc387998 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/105180 Reviewed-by: Wyatt Hepler Commit-Queue: Tim Laurence --- pw_presubmit/py/pw_presubmit/format_code.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pw_presubmit/py/pw_presubmit/format_code.py b/pw_presubmit/py/pw_presubmit/format_code.py index 01523aeb00..425c84a2a1 100755 --- a/pw_presubmit/py/pw_presubmit/format_code.py +++ b/pw_presubmit/py/pw_presubmit/format_code.py @@ -392,15 +392,18 @@ def check_code_format(ctx: pw_presubmit.PresubmitContext): def presubmit_checks( - *, exclude: Collection[Union[str, - Pattern[str]]] = ()) -> Tuple[Callable, ...]: + *, + exclude: Collection[Union[str, Pattern[str]]] = (), + code_formats: Collection[CodeFormat] = CODE_FORMATS +) -> Tuple[Callable, ...]: """Returns a tuple with all supported code format presubmit checks. Args: exclude: Additional exclusion regexes to apply. + code_formats: A list of CodeFormat objects to run checks with. """ - return tuple(presubmit_check(fmt, exclude=exclude) for fmt in CODE_FORMATS) + return tuple(presubmit_check(fmt, exclude=exclude) for fmt in code_formats) class CodeFormatter: