安装使用 pre-commit

pip install pre-commit
cd  github-proj
pre-commit install
vim .pre-commit-config.yaml
# pre-commit run --all-files

.pre-commit-config.yaml

exclude: ^tests/data/
repos:
  - repo: https://gitlab.com/pycqa/flake8.git
    rev: 3.8.3
    hooks:
      - id: flake8
        args: ["--max-line-length=128"]
  - repo: https://gitee.com/xiaodongdong402/seed-isort-config.git
    rev: v2.2.0
    hooks:
      - id: seed-isort-config
  - repo: https://gitee.com/mirrors/isort.git
    rev: 4.3.21
    hooks:
      - id: isort
  - repo: https://gitee.com/mirrors_pre-commit/mirrors-yapf.git
    rev: v0.30.0
    hooks:
      - id: yapf
  - repo: https://gitee.com/wangjing12/pre-commit-hooks.git
    rev: v3.1.0
    hooks:
      - id: trailing-whitespace
      - id: check-yaml
      - id: end-of-file-fixer
      - id: requirements-txt-fixer
      - id: double-quote-string-fixer
      - id: check-merge-conflict
      - id: fix-encoding-pragma
        args: ["--remove"]
      - id: mixed-line-ending
        args: ["--fix=lf"]
  # - repo: https://gitee.com/mirrors_markdownlint/markdownlint.git
  #   rev: v0.11.0
  #   hooks:
  #     - id: markdownlint
  #       args: ["-r", "~MD002,~MD013,~MD029,~MD033,~MD034",
  #             "-t", "allow_different_nesting"]
  - repo: https://gitee.com/mirrors_codespell-project/codespell.git
    rev: v2.1.0
    hooks:
      - id: codespell
  - repo: https://gitee.com/irving512/docformatter.git
    rev: v1.3.1
    hooks:
      - id: docformatter
        args: ["--in-place", "--wrap-descriptions", "79"]
  # - repo: local
  #   hooks:
  #     - id: clang-format
  #       name: clang-format
  #       description: Format files with ClangFormat
  #       entry: clang-format -style=google -i
  #       language: system
  #       files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|cuh|proto)$

参考文档:
https://pre-commit.com

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
pytest和pre-commit是两个不同的工具。pytest是一种用于Python的测试框架,用于编写和运行单元测试。它可以帮助开发者更轻松地编写可靠的测试代码,并提供丰富的断言和测试运行控制功能。 pre-commit是一个用于管理和维护多种语言的git pre-commit hooks框架。它允许你在每次提交代码之前运行预定义的脚本或命令,以执行代码格式化、静态代码分析、代码审查等操作。通过pre-commit,你可以轻松地将他人创建并分享的pre-commit hooks安装到自己的项目仓库中,解决环境依赖问题。 所以,pytest和pre-commit是两个用途不同的工具。pytest主要用于编写和运行单元测试,而pre-commit用于在提交代码之前运行预定义的脚本或命令。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [fondat-aws:Amazon Web Services的Fondat软件包](https://download.csdn.net/download/weixin_42131424/15625298)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [使用哪些工具,可以提升 Python 项目质量?](https://blog.csdn.net/m0_72444380/article/details/126869817)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值