Closed shepilov-vladislav closed 6 months ago
I believe based on the python pre-commit documentation that if I read between the lines there's a git clone
(or an archive tarball downloaded from the latest tag on GitHub) and then a pip install .
in that directory. If the former is more/less true, this isn't a Flake8 only problem. Any python pre-commit hook that includes the tests in its repository will have this issue for you based on where you put the directory.
You can also update how you run pytest. For example you can tell pytest
to not recurse the .cache
directory https://github.com/PyCQA/flake8/blob/5c52d752e64f210369b37654e7b26ce25e2266d6/pytest.ini#L2
You can also just not put the directory in your current repository root in CI. There's many ways to fix this but I don't think this is either a Flake8 bug or a pre-commit bug.
I also strongly discourage running tests in pre-commit as it's far too slow and will frustrated your contributors
how did you install flake8?
unmodified output of
flake8 --bug-report
describe the problem
what I expected to happen
unit tests should not break on CI ...
Gitlab CI Config
commands ran
This happens because the flake8 test directory gets into the pre-commit cache, while the CI cache is in
./.cache/pre-commit/...
and the pytest runner tries to run this test too. I understand that I can change the location of the cache folder, but still it seems to me that this behavior of pre-commit for flake8 is strange and a better solution would be to exclude the tests directory from pre-commit.