--- id: yapf version: "0.43.0" license: Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for… (full text in the JSON record) license_treatment: permissive maintenance: active --- # yapf — A formatter for Python code License: permissive · Maintenance: active · Downloads: 9.2M/mo ## What it is and what it does YAPF is a Python code formatter that automatically rewrites code to match a configured style, based on the clang-format algorithm. Rather than enforcing rules line-by-line, it analyzes the entire code structure and calculates the best formatting that conforms to your chosen style. It supports predefined styles (pep8, google, yapf, facebook) and custom configurations via .style.yapf, setup.cfg, or pyproject.toml files. You can use YAPF as a command-line tool to format files in place, print diffs, or run recursively over directories, or as a Python library by importing FormatCode and FormatFile from yapf.yapflib.yapf_api. It requires Python 3.7 or later and integrates with many editors via community plugins. Use it for: - Enforce consistent code style across a team or project without manual review of formatting details. - Integrate into a CI/CD pipeline to verify that code has been formatted correctly before merging. - Reformat legacy Python code to a modern style guide in bulk. - Use as a library in an IDE or editor plugin to format code on save or on demand. - Configure custom formatting rules for a project and apply them consistently to all Python files. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. YAPF automatically reformats Python code to conform to a specified style guide, calculating the best formatting that matches your chosen style. Yes. YAPF is actively maintained with low install friction, permissive licensing, and no known vulnerabilities. Install it if you want automatic, style-guide-compliant code formatting in your workflow—either as a standalone tool or integrated into your development environment. ## Install pip install yapf uv add yapf poetry add yapf ## Installing yapf Before you install: Low install friction with only two runtime dependencies (platformdirs and tomli). Actively maintained with recent commits and a large repository following (13980 stars). License in practice: Apache License 2.0 is permissive and allows commercial use, modification, and distribution with minimal restrictions—you can use YAPF in proprietary projects as long as you include a copy of the license and note any changes you make. Quickstart: pip install yapf from yapf.yapflib.yapf_api import FormatCode formatted_code, changed = FormatCode("f ( a = 1, b = 2 )") print(formatted_code) Requires Python 3.7 or later (supports 3.7, 3.8, 3.9, 3.10, 3.11) Verify before relying: - Whether YAPF's formatting output is deterministic across different Python versions or systems. - Performance characteristics when formatting very large files or entire codebases. - How well YAPF integrates with modern Python tooling in the same workflow. ## Package facts - License: Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for… (full text in the JSON record) (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 9.2M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags python code formatter, automatic code formatting, style guide enforcement, pep8 formatter, python code beautifier, format python files, code style automation, code-formatter, style-enforcement, cli-tool [View on SkillFed](https://skillfed.io/packages/yapf) · [View on PyPI](https://pypi.org/project/yapf/)