Automatically reformat all Python files in a project to match PEP 8 style with a single command.
Add YAPF as a pre-commit check in your CI pipeline to reject code that does not meet your style rules.
Integrate YAPF with your code editor to auto-format Python files every time you save.
YAPF is a tool that automatically formats Python code so it looks clean and consistent. If you have ever spent time manually adjusting spacing, indentation, or line lengths in a Python file to match a style guide, YAPF does that work for you. You point it at a file, it rewrites the formatting, and you move on. The tool works by calculating the best possible layout for your code according to a chosen style. You can pick from a few built-in styles, including the official Python community style (PEP 8) and Google's internal Python style. You can also create a configuration file to mix and match specific rules, such as how many spaces to use before a comment or whether to break lines before certain operators. YAPF runs from the command line. You can ask it to rewrite files in place, print only the changes it would make, or check whether a file is already formatted correctly (useful for automated checks during software development). It can process a single file, a folder of files, or read code piped in from elsewhere. An option to run on multiple files at once using parallel processing is also available. Many popular code editors have plugins that run YAPF automatically when you save a file, so you may never need to invoke it manually. It installs from the standard Python package index with a single command. The project was originally created at Google but is not an official Google product. The full README is longer than what was shown.
← google on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.