pre-commit.com: Same version in .pre-commit-config.yaml and requirements.txt
Asked Answered
P

1

10

I would like to use the exactly same version of flake8 in requirements.txt and in .pre-commit-config.yaml.

To avoid redundancy I would like to keep the version number of flake8 exactly once in my repo.

Can pre-commit.com read the version number of flake8 from requirements.txt?

Prato answered 28/1, 2021 at 15:30 Comment(1)
Related: browniebroke.com/blog/gh-action-pre-commit-autoupdatePrato
P
0

it cannot

pre-commit intentionally does not read from the repository under test as this makes caching intractable

you can read more in this issue and the many duplicate issues linked there

for me, I no longer include flake8, etc. in my requirements files as pre-commit replaces the need to install linters / code formatters elsewhere


disclaimer: I created pre-commit

Packing answered 28/1, 2021 at 15:40 Comment(2)
I know this seems like a closed issue on the part of the lib creator, but to be fair pre-commit doesn't really "replace" the need to install linters - eg. we run our checks on CI, where pre-commit does not make sense, and it should run regardless of what the user has installed on his local machine (eg. his precommit install is wrong/broken/bypassed). This means having versions on requirements.txt + config.yaml, which is painful to maintain (eg. having to manually update dependabot PRs)Graniteware
pre-commit works great as a CI tool, so yes it doesPacking

© 2022 - 2024 — McMap. All rights reserved.