Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hooks: add poetry-update hook #8327

Merged
merged 9 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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