# 使用 Homebrew, Nix, pacman, apt 安装 yapf

查看 yapf 的安装路径、可执行文件、元数据以及面向 AI 代理工作流的安全说明。

## 安装

```sh
sudo av install brew:yapf
```

其他安装命令:

### macOS

- Homebrew (100%):

```sh
brew install yapf
```

  证据: local Homebrew formula metadata

### Linux

- Nix (92%):

```sh
nix profile install nixpkgs#yapf
```

  证据: nixpkgs package indexes: yapf from https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/top-level/all-packages.nix

- pacman (92%):

```sh
sudo pacman -S yapf
```

  证据: Arch Linux sync databases: yapf from https://geo.mirror.pkgbuild.com/extra/os/x86_64/extra.db.tar.gz

- Debian apt (92%):

```sh
sudo apt install python3-yapf
```

  证据: Debian stable package indexes: python3-yapf from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz

## 软件包事实

- **软件包键:** brew:yapf
- **软件包管理器:** Homebrew
- **版本:** 0.43.0
- **来源摘要:** Formatter for python code
- **主页:** <https://github.com/google/yapf>
- **仓库:** <https://github.com/google/yapf>
- **已生成:** 2026-08-03T19:37:03+00:00

## 可执行文件

- yapf (别名)
- yapf-diff (别名)

## 安装行为

- Bottle: 不可用

## 版本和新鲜度

- 页面生成时间: 2026-08-03
- 管理器版本: 0.43.0
## 项目历史与用法

YAPF, Yet Another Python Formatter, is Google's clang-format-inspired formatter for Python source. Unlike style checkers that only report or repair selected PEP 8 violations, YAPF searches for a low-cost layout that conforms to a chosen style and rewrites the file.

### 项目历史

The Google-owned GitHub repository was created on 2015-03-18, and PyPI history shows public 0.1.x packages in April 2015. The README explicitly says YAPF is based on clang-format, developed by Daniel Jasper, and that its goal is to produce code as good as a programmer would write while following a style guide.

YAPF's design grew out of formatter culture rather than linter culture. Its README contrasts the project with tools that remove lint errors and emphasizes a configurable formatting engine with named styles such as pep8, google, yapf, and facebook plus many individual knobs. Later changelog entries show continued maintenance for newer Python syntax and packaging shifts, including the move away from lib2to3 toward blib2to3 for Python 3.11-era parsing.

### 采用历史

YAPF became one of the main Python auto-formatters of the mid-2010s, especially for teams that wanted clang-format-style configurability instead of a single canonical layout. Its README documents editor integrations, recursive formatting, diff mode for CI checks, local style discovery, and ignore files, all of which match adoption through developer tooling, pre-submit checks, and editor save hooks.

The formatter's long-term place changed after Black popularized less-configurable formatting, but YAPF remained important where repositories wanted Google/Facebook-like styles, large configuration surfaces, or incremental compatibility with existing formatting policy.

### 使用方式

Typical CLI usage is `yapf -i file.py` for in-place formatting, `yapf -d` for a diff suitable for review or CI, and `yapf -r` for recursive directory formatting. The `yapf-diff` helper fits patch-oriented workflows by formatting only changed hunks.

Configuration is central to YAPF usage. The formatter searches local style files such as `.style.yapf`, `setup.cfg`, and `pyproject.toml`, supports predefined base styles, and offers many style options for projects that treat formatting as policy rather than taste.

### 为什么软件包爱好者会关心

YAPF matters because it represents the configurable branch of Python formatter history: closer to clang-format and gofmt in automation, but less doctrinaire than later formatters. In package collections it is a standard example of a developer tool whose value is mostly in repeatability, editor integration, and reducing style churn in diffs.

It also shows how Python tooling had to adapt as the language parser story changed. Maintaining a formatter across Python syntax releases is partly a packaging problem: the executable must track language versions, config formats, editor plugins, and CI behavior at the same time.

### 时间线

- 2015-03-18: google/yapf repository is created on GitHub.
- 2015-04-07: PyPI records an early public 0.1.4 upload.
- 2023-06-13: YAPF 0.40.0 changelog notes Python 3.11 support and replacement of lib2to3 with blib2to3.
- 2023-09-22: YAPF 0.40.2 is published on PyPI.
- 2024-11-14: YAPF 0.43.0 is published on PyPI.

### Related projects

- clang-format is the formatter model named by YAPF's README.
- autopep8 and pep8ify are older Python formatting tools contrasted by YAPF's documentation.
- Black is the later opinionated Python formatter often compared with YAPF in formatter choice discussions.

### 来源

- <https://api.github.com/repos/google/yapf>
- <https://github.com/google/yapf>
- <https://pypi.org/pypi/yapf/json>
- <https://raw.githubusercontent.com/google/yapf/main/CHANGELOG.md>
- <https://raw.githubusercontent.com/google/yapf/main/README.md>


## 安全说明

narrow executable package without higher-risk signals.

- **Geiger 风险:** 绿色 / 低
- narrow executable package without higher-risk signals


## Configuration and credential file locations

These source-backed paths show where this package keeps local settings or durable credentials. Automic Vault can use them as review targets for secret scanning, migration, and command approval.


## Configuration files

- Unix: .style.yapf, setup.cfg, pyproject.toml, ~/.config/yapf/style, .yapfignore
## 其他软件包管理器记录

- Debian apt - python3-yapf - 0.40.2-3: normalized package name match | Debian stable package indexes: python3-yapf from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | public modules for yapf (Python 3) | https://github.com/google/yapf
- Debian apt - yapf3 - 0.40.2-3: normalized package name match | Debian stable package indexes: yapf3 from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | Python code formatter for different styles (Python 3) | https://github.com/google/yapf
- Nix - yapf: normalized package name match | nixpkgs package indexes: yapf from https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/top-level/all-packages.nix
- Ubuntu apt - python3-yapf - 0.33.0-1: normalized package name match | Ubuntu 24.04 LTS package indexes: python3-yapf from https://archive.ubuntu.com/ubuntu/dists/noble/universe/binary-amd64/Packages.gz | public modules for yapf (Python 3) | https://github.com/google/yapf
- Ubuntu apt - yapf3 - 0.33.0-1: normalized package name match | Ubuntu 24.04 LTS package indexes: yapf3 from https://archive.ubuntu.com/ubuntu/dists/noble/universe/binary-amd64/Packages.gz | Python code formatter for different styles (Python 3) | https://github.com/google/yapf
- pacman - yapf - 0.43.0-2: normalized package name match | Arch Linux sync databases: yapf from https://geo.mirror.pkgbuild.com/extra/os/x86_64/extra.db.tar.gz | Python style guide checker | https://github.com/google/yapf


## Combined YAML source

View the package source record on GitHub. [combined/yapf.yml](https://github.com/mxcl/pkgdb/blob/main/combined/yapf.yml)


## 来源

- pkg.so package database
- Geiger risk classifier
- curated configuration and credential file locations
- curated package history
- pkgdb category and tag curation
- external package-manager database matches
- cross-ecosystem install command graph
