zoukankan      html  css  js  c++  java
  • pre-commit hooks在python项目中的使用

    在使用pre-commit hooks之前,需要先安装pre-commit

    pip install pre-commit

    一、新建.pre-commit-config.yaml文件,并在里面配置你所需要的验证规则

    default_stages: [commit]
    repos:
      - repo: https://github.com/yingzi113/pre-commit-hooks
        rev: 5863e162f1bed1f63eeb716e77d622ff8e3d9af9
        hooks:
        - id: check-case-conflict
      - repo: https://github.com/pre-commit/mirrors-autopep8
        rev: v1.4.4
        hooks:
        - id: autopep8
          args: [-i, --global-config=.flake8, -v]
      - repo: https://github.com/pre-commit/pre-commit-hooks
        rev: v2.4.0
        hooks:
        - id: flake8

    二、install pre-commit

    进入虚拟环境,安装pre-commit

     pre-commit install

    安装结果如下:

     查看安装的pre-commit

    cd .git/hooks

    ls -l

     安装成功!

    三、运行所配置的文件规则

    pre-commit run --all-files

    运行结果如图所示。 

  • 相关阅读:
    08简单推导:手机尾号评分
    07简单推导:生日蜡烛
    06普通推导
    05简单推导:猴子吃桃
    简单推导
    03map用法
    List题目
    02List的使用
    01基础知识
    HDU
  • 原文地址:https://www.cnblogs.com/wangyingblock/p/11984463.html
Copyright © 2011-2022 走看看