I'm trying to get pre-commit working at work (I have it working on personal computer). Our security setup will not allow pre-commit to reference external repos and pip install external packages from them.
It seems like my options are:
- Keep a copy of needed repositories on local git server
- Setup .pre-commit-config.yml to use local repo
Before I decide which path to take, I want to know more about how the local repo works, but can't find a lot of documentation on the specifics on the pre-commit website (or elsewhere).
I've got the .pre-commit-config.yml setup like the example below.
repos:
- repo: local
hooks:
- id: isort
name: Run isort
entry: isort
language: system
- id: black
name: Run black
entry: black
language: system
- id: flake8
name: Run flake8
entry: flake8
language: system
- id: pydocstyle
name: Run pydocstyle
entry: pydocstyle
language: system
If I use the above .pre-commit-config.yml, what system versions of the packages are used? Is it the version in the active conda environment (I'm using conda)? I thought that would be the case, but the pre-commit hooks appear to be running even though I don't have isort
, black
, and flake8
or pydocstyle
in the activated conda environment.
That seems odd to me, but I can't find anything online to confirm what system versions of those packages will be used in the local repository setup.
Also, what happens if I use language: python
instead of language: system
?
I'm also open if anyone else has any ideas about a way to use pre-commit with the security restrictions I face besides what I've outlined.
types: [python]
will that just run on any Python files in the commit? Also, is there a way to setup pre-commit so it downloads and setups up the needed packages from Anaconda? I have a constraint that things must come from Anaconda's repositories at the moment (which is why I'm considering using the local repo with language: system). – Virgil