Skip to content

fix: run pytest hook on unstaged files#347

Merged
jenstroeger merged 2 commits intostagingfrom
fix-make-test
Oct 28, 2022
Merged

fix: run pytest hook on unstaged files#347
jenstroeger merged 2 commits intostagingfrom
fix-make-test

Conversation

@jenstroeger
Copy link
Copy Markdown
Owner

Note that all make check variants run their pre-commit hooks on unstaged files by using the --all-files command line option:

check-bandit:
pre-commit run bandit --all-files
check-flake8:
pre-commit run flake8 --all-files
check-lint:
pre-commit run pylint --all-files
check-mypy:
pre-commit run mypy --all-files
check:
pre-commit run --all-files

However, running make test does not specify that option

test:
pre-commit run pytest --hook-stage push

and thus stashes changes before running:

> make test
pre-commit run pytest --hook-stage push
[WARNING] Unstaged files detected.
[INFO] Stashing unstaged files to /path/to/.cache/pre-commit/patch1666240262-62070.
Run unit tests...........................................................Passed
- hook id: pytest
- duration: 0.9s

...
============================== 1 passed in 0.35s ===============================

[INFO] Restored changes from /path/to/.cache/pre-commit/patch1666240262-62070.

This change uses the --files command line option (which is similar to the --all-files) and now make test no longer stashes changes before running.

@jenstroeger jenstroeger requested a review from behnazh October 20, 2022 04:46
@jenstroeger jenstroeger merged commit 22a020a into staging Oct 28, 2022
@jenstroeger jenstroeger deleted the fix-make-test branch October 30, 2022 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants