Below is my .pre-commit-config.yaml file for my project.
# See https://pre-commit.com/hooks.html for more hooks
fail_fast: true
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: local
hooks:
- id: isort
name: isort
entry: isort
language: python
types: [python]
- repo: local
hooks:
- id: black
name: black
entry: black
language: python
types: [python]
- repo: local
hooks:
- id: pytest-check
name: pytest-check
#entry: pytest tests/test_file2.py
entry: pytest
language: python
#args: [--maxfail=1]
#stages: [post-commit]
pass_filenames: false
always_run: false
I would like to achieve two things as described below.
FYI. - I have already explored one approach to bypass pre-commit but it's applicable to all hook mentioned in the .pre-commit-config.yaml file.
How can we achieve all two scenario? Please suggest your input on the same?
Make your test into a shell script that executes, in effect,
pytest tests/test_file2.py (or whatever you are doing now)
true
The last command could also be exit 0
, or anything else that exits successfully.) That way the tests will run, with the side effects and output that you have now, but git will always treat them as successful.