主页

索引

模块索引

搜索页面

pre-commit

安装:

pip install pre-commit

# 验证
$ pre-commit --version

Quick start:

1. Install pre-commit
$ pre-commit --version
pre-commit 3.7.1


2. Add a pre-commit configuration
    create a file named .pre-commit-config.yaml
    $ cat .pre-commit-config.yaml:
    repos:
    -   repo: https://github.com/pre-commit/pre-commit-hooks
        rev: v2.3.0
        hooks:
        -   id: check-yaml
        -   id: end-of-file-fixer
        -   id: trailing-whitespace
    -   repo: https://github.com/psf/black
        rev: 22.10.0
        hooks:
        -   id: black


3. Install the git hook scripts
    $ pre-commit install
    pre-commit installed at .git/hooks/pre-commit
    # now pre-commit will run automatically on git commit!

4. (optional) Run against all the files

示例

主页

索引

模块索引

搜索页面