From 94c6b0d7281451fc705dec8c4c4249a38797c7a6 Mon Sep 17 00:00:00 2001 From: Ryan Kuester Date: Tue, 1 Oct 2024 16:17:45 -0500 Subject: [PATCH] style: add .style.yapf to control yapf styling of Python code Add a .style.yapf file so yapf can be used to style Python code without passing the project's style via command line option. Remove the corresponding patch to pigweed's call to yapf, used by CI, and instead let it too rely on .style.yapf. Remove the developer documentation's instruction to use the command line option. --- .style.yapf | 3 +++ CONTRIBUTING.md | 2 +- tensorflow/lite/micro/tools/make/pigweed.patch | 9 --------- 3 files changed, 4 insertions(+), 10 deletions(-) create mode 100644 .style.yapf diff --git a/.style.yapf b/.style.yapf new file mode 100644 index 00000000000..de72b98c2c8 --- /dev/null +++ b/.style.yapf @@ -0,0 +1,3 @@ +[style] +based_on_style = pep8 +indent_width = 2 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e1410af4f91..102614d4369 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -190,7 +190,7 @@ Below are some tips that might be useful and improve the development experience. ``` pip install yapf - yapf log_parser.py -i --style='{based_on_style: pep8, indent_width: 2}' + yapf log_parser.py -i' ``` * Add a git hook to check for code style etc. prior to creating a pull request: diff --git a/tensorflow/lite/micro/tools/make/pigweed.patch b/tensorflow/lite/micro/tools/make/pigweed.patch index d1e29304e79..9aa2044e307 100644 --- a/tensorflow/lite/micro/tools/make/pigweed.patch +++ b/tensorflow/lite/micro/tools/make/pigweed.patch @@ -14,15 +14,6 @@ diff --git a/pw_presubmit/py/pw_presubmit/format_code.py b/pw_presubmit/py/pw_pr index 19d09546..c1ff6b5a 100755 --- a/pw_presubmit/py/pw_presubmit/format_code.py +++ b/pw_presubmit/py/pw_presubmit/format_code.py -@@ -142,7 +142,7 @@ def fix_go_format(files: Iterable[Path]) -> None: - - - def _yapf(*args, **kwargs) -> subprocess.CompletedProcess: -- return log_run(['python', '-m', 'yapf', '--parallel', *args], -+ return log_run(['python', '-m', 'yapf', '--style', '{based_on_style:pep8,indent_width:2}', '--parallel', *args], - capture_output=True, - **kwargs) - @@ -229,11 +229,6 @@ def print_format_check(errors: Dict[Path, str], except ValueError: return Path(path).resolve()