Skip to content

Commit

Permalink
Add pre-commit hooks and code formatting guidelines (srbhr#250)
Browse files Browse the repository at this point in the history
* Add pre-commit hooks and code formatting guidelines

* Update pre-commit hooks and add autopep8 hook

* Add setup-cfg-fmt hook to pre-commit-config.yaml

* Add pre-commit installation instructions
  • Loading branch information
Devasy23 authored Mar 29, 2024
1 parent 0c5323f commit 62b6ec3
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 6 deletions.
57 changes: 57 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: debug-statements
- id: double-quote-string-fixer
- id: name-tests-test
- id: requirements-txt-fixer
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v2.5.0
hooks:
- id: setup-cfg-fmt
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.9.2
hooks:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
- repo: https://github.com/PyCQA/docformatter
rev: v1.7.1
hooks:
- id: docformatter
additional_dependencies: [tomli]
args: [--in-place, --config, ./pyproject.toml]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
exclude: ^(docs/|example-plugin/)
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/pycqa/pydocstyle
rev: 6.3.0
hooks:
- id: pydocstyle
- repo: https://github.com/myint/eradicate
rev: '2.2.0'
hooks:
- id: eradicate
args: []
- repo: https://github.com/hhatto/autopep8
rev: v2.1.0
hooks:
- id: autopep8
34 changes: 28 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Follow these steps to set up the environment and run the application.
sudo apt-get install python-tk python3-tk tk-dev
sudo apt-get install build-essential zlib1g-dev libffi-dev libssl-dev libbz2-dev libreadline-dev libsqlite3-dev liblzma-dev
```

- pyenv installer
Expand All @@ -109,12 +109,12 @@ Follow these steps to set up the environment and run the application.
```
pyenv install -v 3.11.0
```
- pyenv with virtual enviroment

- pyenv with virtual enviroment
```
pyenv virtualenv 3.11.0 venv
```

- Activate virtualenv with pyenv
```
pyenv activate venv
Expand Down Expand Up @@ -195,6 +195,29 @@ To run the full stack web application (frontend client and backend api servers),
<br/>
## Code Formatting
This project uses [Black](https://black.readthedocs.io/en/stable/) for code formatting. We believe this helps to keep the code base consistent and reduces the cognitive load when reading code.
Before submitting your pull request, please make sure your changes are in accordance with the Black style guide. You can format your code by running the following command in your terminal:
```sh
black .
```
## Pre-commit Hooks
We also use [pre-commit](https://pre-commit.com/) to automatically check for common issues before commits are submitted. This includes checks for code formatting with Black.
If you haven't already, please install the pre-commit hooks by running the following command in your terminal:

```sh
pip install pre-commit
pre-commit install
```

Now, the pre-commit hooks will automatically run every time you commit your changes. If any of the hooks fail, the commit will be aborted.

## Join Us, Contribute!

Pull Requests & Issues are not just welcomed, they're celebrated! Let's create together.
Expand All @@ -209,5 +232,4 @@ Pull Requests & Issues are not just welcomed, they're celebrated! Let's create t

🚀 Explore and improve our [Landing Page](https://github.com/srbhr/website-for-resume-matcher). PRs always welcome!

📚 Contribute to the [Resume Matcher Docs](https://github.com/srbhr/Resume-Matcher-Docs) and help people get started with using the software.
📚 Contribute to the [Resume Matcher Docs](https://github.com/srbhr/Resume-Matcher-Docs) and help people get started with using the software.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,31 @@ To run the full stack web application (frontend client and backend api servers),
<div align="center">
## Code Formatting
This project uses [Black](https://black.readthedocs.io/en/stable/) for code formatting. We believe this helps to keep the code base consistent and reduces the cognitive load when reading code.
Before submitting your pull request, please make sure your changes are in accordance with the Black style guide. You can format your code by running the following command in your terminal:
```sh
black .
```
## Pre-commit Hooks
We also use [pre-commit](https://pre-commit.com/) to automatically check for common issues before commits are submitted. This includes checks for code formatting with Black.
If you haven't already, please install the pre-commit hooks by running the following command in your terminal:

```sh
pip install pre-commit
pre-commit install
```

Now, the pre-commit hooks will automatically run every time you commit your changes. If any of the hooks fail, the commit will be aborted.


## Join Us, Contribute!

</div>
Expand Down

0 comments on commit 62b6ec3

Please sign in to comment.