Python formatting using `git cl format --python` not working

8 views
Skip to first unread message

Tim

unread,
Aug 20, 2024, 4:19:13 PM8/20/24
to python
I'm trying to get auto python formatting going in a directory (specifically //tools/json_schema_compiler/) but intentionally adding some formatting issues to a file (trailing whitespace, long code line, long comment line) and running `git cl format --python` doesn't seem to be doing anything?

There is a `.style.yapf` in the parent directory (//tools/), but I've also tried manually adding a new one into my directory but that didn't change anything. Has anyone run into something similar and know what might be going on?

Peter Wen

unread,
Aug 20, 2024, 4:22:03 PM8/20/24
to Tim, python
I have seen this before and I've found it helpful to do some printf debugging by adding prints in depot_tools/git_cl.py directly when it invokes yapf. That helped me last time to pinpoint the error and see the actual yapf command and repro it locally.

Hope it helps!
Peter

On Tue, Aug 20, 2024 at 4:19 PM Tim <tjud...@chromium.org> wrote:
I'm trying to get auto python formatting going in a directory (specifically //tools/json_schema_compiler/) but intentionally adding some formatting issues to a file (trailing whitespace, long code line, long comment line) and running `git cl format --python` doesn't seem to be doing anything?

There is a `.style.yapf` in the parent directory (//tools/), but I've also tried manually adding a new one into my directory but that didn't change anything. Has anyone run into something similar and know what might be going on?

--
You received this message because you are subscribed to the Google Groups "python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python+un...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/python/CABOZv713Br-GdpVYCKX%3DuOkR%3DWXrm0McWD_Vs5r5K_zt7AFQBw%40mail.gmail.com.

Tim

unread,
Aug 20, 2024, 4:53:33 PM8/20/24
to Peter Wen, python
Aha thanks! Adding some prints I saw it wasn't being run at all and from that I was able to track down this line, which disables yapf for that folder entirely.

And turns out there's already an associated bug to try and enable it for the folder too :)

Peter Wen

unread,
Aug 20, 2024, 5:08:51 PM8/20/24
to Tim, python
Awesome job! 👍
Reply all
Reply to author
Forward
0 new messages