YAPF (Yet Another Python Formatter) is an opinionated code formatter for Python, developed by Google. It automatically re-formats Python code to conform to the PEP 8 style guide and other configurable style conventions, aiming to improve code readability and consistency. The current version is 0.43.0, and it generally follows a stable release cadence with updates for Python version support and bug fixes.
pip install yapfVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to use `FormatCode` to programmatically format a string of Python code, including an example of applying a specific style configuration.
Ensure your environment uses Python 3.7 or a later version. Upgrade your Python interpreter if necessary.
To modify files in-place, always use the `-i` or `--in-place` flag (e.g., `yapf -i file.py`).
Pass `style_config='google'` (or other predefined styles), or a dictionary of style options directly to `FormatCode`. For file-based configuration, load it manually and pass the dictionary, or invoke YAPF via its CLI which handles file discovery.
Avoid relying on YAPF's internal AST structures. If you need to manipulate ASTs, use `libcst` directly or ensure your integration is compatible with the new underlying library.
No dependency data recorded yet.