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

chore: add pre-commit and gitlint #97

Merged
merged 2 commits into from
Jan 16, 2024
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
3 changes: 3 additions & 0 deletions .gitlint
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[general]
contrib=contrib-title-conventional-commits
ignore=B6
25 changes: 25 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-added-large-files
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: detect-private-key
- repo: https://github.com/jorisroovers/gitlint
rev: v0.19.1
hooks:
- id: gitlint
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.11
hooks:
- id: ruff
args: ["--fix", "--fixable", "F401"]
- id: ruff-format
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,13 @@ We recommend using VS Code as IDE.
* Install the [poetry](https://python-poetry.org/) dependency management tool and add it to your `PATH`
* Run `poetry config virtualenvs.in-project true` to have `poetry` create the virtual environment inside the project directory
> *This is recommended for compatibility with VS Code*
* Run `poetry install --no-root --with dev` to install dependencies and setup the virtual environment
* Run `poetry install --with dev` to install dependencies and setup the virtual environment
* Install the recommended extensions in VS Code
* Select the Python interpreter to be `.venv/bin/python.exe` (Linux) or `.venv/Scripts/python.exe` (Windows) in VS Code

Your environment should now be setup to contain all dev and non-dev dependencies and VS Code will automatically highlight and fix issues detected by `ruff` and `mypy`.

To setup `pre-commit` for automatic issue detection while committing you need to run the following commands:
* `poetry run pre-commit install`
* `poetry run pre-commit install --hook-type commit-msg`
* `poetry run pre-commit install-hooks`
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,9 @@ voluptuous-stubs = "^0.1.1"
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.ruff]
unfixable = ["F401"]

[tool.mypy]
check_untyped_defs = true
explicit_package_bases = true