Skip to content

Commit

Permalink
[feature] add hooks for using with pre-commit (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
rrauenza authored Oct 23, 2022
1 parent 0c42bd0 commit d295256
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- id: deptry
name: deptry
description: deptry is a command line tool to check for issues with dependencies in a Python project, such as obsolete or missing dependencies.
entry: deptry .
language: system
always_run: true
pass_filenames: false
28 changes: 27 additions & 1 deletion docs/docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,30 @@ An example of the contents of the resulting `deptry.json` file is as follows:
"transitive": [],
"misplaced_dev": []
}
```
```

## usage in pre-commit

_deptry_ can be added to your [pre-commit](https://pre-commit.com/) rules. Here is
an example config for your .pre-commit-config.yaml file:

```
- repo: https://github.com/fpgmaas/deptry.git
rev: <tag>
hooks:
- id: deptry
args:
- "--skip-missing"
```

Replace <tag> with one of the [tags](https://github.com/fpgmaas/deptry/tags) from the
project or a specific commit.

!!! note

This will only pull in the pre commit hooks config file from the version you have specified. The
actual deptry that will be run will be the first one found in your path, so you will need
to add deptry to your local Python virtual environment.

This requirement is due to deptry needing to be running within the same Python virtual environment
whose dependencies it is analyzing.

0 comments on commit d295256

Please sign in to comment.