Skip to content

Move YAPF style setting to a project-wide .style.yapf file#1038

Open
mhucka wants to merge 9 commits intotensorflow:masterfrom
mhucka:add-yapf-config
Open

Move YAPF style setting to a project-wide .style.yapf file#1038
mhucka wants to merge 9 commits intotensorflow:masterfrom
mhucka:add-yapf-config

Conversation

@mhucka
Copy link
Copy Markdown
Member

@mhucka mhucka commented Apr 10, 2026

Scripts and workflows that run yapf currently each add the option --style=google to the invocation of yapf. To follow best practices, this PR adds a .style.yapf configuration file at the top level of the project to set the style, and removes the flag from where it was added on the command line explicitly.

The use of a config file has the following benefits:

  • It lets tools like IDEs discover the setting automatically.
  • It reduces the chances that developers will forget to add the flag when they run yapf directly on the command line for quick checks, or write new scripts that use yapf.
  • It communicates intentions more clearly to new contributors.

Removing the flag from the scripts is not strictly necessary (everything will work the same if there is both a config file and the flag is passed to yapf). However, if a config file is used, it's better for maintainability and consistency to also remove the flag from individual invocations.

Note: the CI will fail the lint check until PR #1047 is merged.

Set the YAPF style to Google style.
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a .style.yapf configuration file to set the Python formatting style to Google. The review feedback suggests updating existing formatting scripts to remove hardcoded style flags, ensuring this new file serves as the single source of truth, and recommends adding a .clang-format file for C++ consistency.

Comment thread .style.yapf
@mhucka mhucka changed the title Add a .style.yapf Move YAPF style setting to a project-wide .style.yapf file Apr 10, 2026
Moved the style setting to the config file.
@mhucka
Copy link
Copy Markdown
Member Author

mhucka commented Apr 10, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request centralizes the YAPF configuration by introducing a .style.yapf file and removing redundant style flags from the formatting scripts. Feedback suggests invoking yapf via python3 -m in format_check.sh for better environment consistency and providing the filename parameter to the YAPF API in format_ipynb.py to ensure the new configuration file is properly detected.

Comment thread scripts/format_check.sh Outdated
Comment thread scripts/format_ipynb.py Outdated
mhucka added 4 commits April 14, 2026 19:56
The invocation in this script was inconsistent with how the other
scripts did it.
Providing the path to the file allows yapf to find the config file.
@mhucka
Copy link
Copy Markdown
Member Author

mhucka commented Apr 14, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request centralizes the YAPF formatting configuration by adding a .style.yapf file and removing redundant --style=google flags from various scripts. It also extends formatting coverage to the scripts directory and standardizes the yapf invocation method. A review comment suggests optimizing format_all.sh by combining multiple yapf calls into a single execution to reduce overhead.

Comment thread scripts/format_all.sh Outdated
mhucka and others added 3 commits April 14, 2026 13:16
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@mhucka mhucka marked this pull request as ready for review April 16, 2026 22:30
@mhucka mhucka added the area/devops Involves build systems, Make files, Bazel files, continuous integration, and/or other DevOps topics label Apr 16, 2026
@mhucka mhucka requested a review from MichaelBroughton April 17, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/devops Involves build systems, Make files, Bazel files, continuous integration, and/or other DevOps topics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants