Skip to content

Commit 53e7f27

Browse files
Spitfire1900chrysledukecat0
authored
Add pre-commit hook to run arbitrary entry points (#981)
Co-authored-by: chrysle <[email protected]> Co-authored-by: Jason Lam <[email protected]>
1 parent 502a7e3 commit 53e7f27

File tree

5 files changed

+32
-0
lines changed

5 files changed

+32
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ dist
88
activate
99
__pypackages__
1010
venv
11+
.venv
1112
.DS_Store
1213
.tox
1314
__pycache__

.pre-commit-hooks.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
- id: pipx
2+
name: pipx
3+
entry: pipx run
4+
require_serial: true
5+
language: python
6+
minimum_pre_commit_version: '2.9.2'

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- Pass `pip_args` to `shared_libs.upgrade()`
55
- Fallback to user's log path if the default log path (`$PIPX_HOME/logs`) is not writable to aid with pipx being used for multi-user (e.g. system-wide) installs of applications
66
- Fix wrong interpreter usage when injecting local pip-installable dependencies into venvs
7+
- add pre-commit hook support
78

89
## 1.2.0
910

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ The zipapp can be downloaded from [Github releases](https://github.com/pypa/pipx
7878
python pipx.pyz ensurepath
7979
```
8080

81+
### Use with pre-commit
82+
83+
pipx [has pre-commit support](docs/installation.md#pre-commit).
84+
8185
### Shell completions
8286

8387
Shell completions are available by following the instructions printed with this command:

docs/installation.md

+20
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,26 @@ The zipapp can be downloaded from [Github releases](https://github.com/pypa/pipx
3838
python pipx.pyz ensurepath
3939
```
4040

41+
<a name="pre-commit"></a>Or use with pre-commit:
42+
43+
Pipx has [pre-commit](https://pre-commit.com/) support. This lets you run applications:
44+
* That can be run using `pipx run` but don't have native pre-commit support.
45+
* Using its prebuilt wheel from pypi.org instead of building it from source.
46+
* Using pipx's `--spec` and `--index-url` flags.
47+
48+
Example configuration for use of the code linter [yapf](https://github.com/google/yapf/). This is to be added to your `.pre-commit-config.yaml`.
49+
50+
```yaml
51+
- repo: https://github.com/pypa/pipx
52+
rev: 1.2.0
53+
hooks:
54+
- id: pipx
55+
alias: yapf
56+
name: yapf
57+
args: ['yapf', '-i']
58+
types: ['python']
59+
```
60+
4161
### Installation Options
4262
4363
The default binary location for pipx-installed apps is `~/.local/bin`. This can be overridden with the environment variable `PIPX_BIN_DIR`.

0 commit comments

Comments
 (0)