Skip to content

Commit

Permalink
hooks: add poetry-update hook (#8327)
Browse files Browse the repository at this point in the history
Co-authored-by: Aljoscha Gerber <[email protected]>
  • Loading branch information
alsmnn and Aljoscha Gerber authored Aug 28, 2023
1 parent 237dff0 commit d0bd8a8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,12 @@
pass_filenames: false
files: ^(.*/)?poetry\.lock$
args: ["-f", "requirements.txt", "-o", "requirements.txt"]

- id: poetry-install
name: poetry-install
description: run poetry install to install dependencies from the lock file
entry: poetry install
language: python
pass_filenames: false
stages: [post-checkout, post-merge]
always_run: true
14 changes: 14 additions & 0 deletions docs/pre-commit-hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ hooks:
args: ["--dev", "-f", "requirements.txt", "-o", "requirements.txt"]
```

## poetry-install

The `poetry-install` hook calls the `poetry install` command to make sure all locked packages are installed.
In order to install this hook, you either need to specify `default_install_hook_types`, or you have
to install it via `pre-commit install --install-hooks -t post-checkout -t post-merge`.

### Arguments

The hook takes the same arguments as the poetry command.
For more information see the [install command]({{< relref "cli#install" >}}).

## Usage

For more information on how to use pre-commit please see the [official documentation](https://pre-commit.com/).
Expand All @@ -97,6 +108,7 @@ repos:
- id: poetry-check
- id: poetry-lock
- id: poetry-export
- id: poetry-install
```

A `.pre-commit-config.yaml` example for a monorepo setup or if the `pyproject.toml` file is not in the root directory:
Expand All @@ -112,6 +124,8 @@ repos:
args: ["-C", "./subdirectory"]
- id: poetry-export
args: ["-C", "./subdirectory", "-f", "requirements.txt", "-o", "./subdirectory/requirements.txt"]
- id: poetry-install
args: ["-C", "./subdirectory"]
```

## FAQ
Expand Down

0 comments on commit d0bd8a8

Please sign in to comment.