Skip to content

Commit

Permalink
Add documentation for pre-commit hook
Browse files Browse the repository at this point in the history
Signed-off-by: Priyanshi Gaur <[email protected]>
  • Loading branch information
nox1134 committed Mar 12, 2024
1 parent 34cc9a5 commit bb3fbb5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
3 changes: 1 addition & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ repos:
- --fix=no
- id: trailing-whitespace

repos:
- repo: local
hooks:
- id: black
Expand All @@ -55,4 +54,4 @@ repos:
name: "isort"
entry: isort --filter-files
language: system
types: ["file", "python", "text"]
types: ["file", "python", "text"]
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,26 @@ follow these steps:
### Static analysis
#### Using [`pre-commit`][pre-commit]
1. Install pre-commit
- Using pip:
```shell
pip install pre-commit
```
- Using homebrew:
```shell
brew install pre-commit
```
2. Install the git hook scripts
```shell
pre-commit install
```
It will run on every commit automatically.
#### Using [`dev/tools.sh`][tools-sh] helper script
The [`dev/tools.sh`][tools-sh] helper script runs the static analysis tools
(`black`, `flake8`, and `isort`):
```shell
Expand All @@ -89,6 +109,7 @@ directories to check:
```
[tools-sh]: /dev/tools.sh
[pre-commit]: https://pre-commit.com/
### Resources
Expand All @@ -100,12 +121,14 @@ directories to check:
- [isort][isort]: _A Python utility / library to sort imports_
- (It doesn't import any libraries, it only sorts and formats them.)
- [ppypa/pipenv][pipenv]: _Python Development Workflow for Humans._
- [pre-commit][pre-commit]: A framework for managing and maintaining multi-language pre-commit hooks.

[ccospyguide]: https://opensource.creativecommons.org/contributing-code/python-guidelines/
[black]: https://github.com/psf/black
[flake8]: https://gitlab.com/pycqa/flake8
[isort]: https://pycqa.github.io/isort/
[pipenv]: https://github.com/pypa/pipenv
[pre-commit]: https://pre-commit.com/


### GitHub Actions
Expand All @@ -115,7 +138,7 @@ GitHub Actions workflow performs static analysis (`black`, `flake8`, and
`isort`) on committed changes. The workflow is triggered automatically when you
push changes to the main branch or open a pull request.

[workflow-static-analysis]: .github/workflows/python_static_analysis.yml
[workflow-static-analysis]: .github/workflows/static_analysis.yml


## Data sources
Expand Down

0 comments on commit bb3fbb5

Please sign in to comment.