Skip to content

Commit

Permalink
Add pre-commit-hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
k9845 authored and thenav56 committed Jun 11, 2024
1 parent 2e74006 commit 38d8481
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 2 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Python check

on:
push:
branches:
- develop
pull_request:


jobs:
pre_commit_checks:
name: 🚴 Pre-Commit checks 🚴
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@main
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@main
with:
cache: 'poetry'
- run: poetry install
- uses: pre-commit/action@main
31 changes: 31 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
default_language_version:
python: python3

# NOTE: Update in .flake8 pyproject.toml as well
exclude: |
(?x)^(
\.git|
__pycache__|
.*snap_test_.*\.py|
.+\/.+\/migrations\/.*|
legacy|
\.venv
)
repos:
- repo: https://github.com/psf/black
rev: 24.3.0
hooks:
- id: black
# args: ["--check"]

- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
# args: ["--check"]

- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
17 changes: 15 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ reportMissingImports = true
reportMissingTypeStubs = false

[tool.black]
line-length = 125
line-length = 130
py36 = true
include = '\.pyi?$'
exclude = '''
Expand All @@ -126,7 +126,20 @@ exclude = '''
| docs
)/
'''
extend-exclude = '^.*\b(migrations)\b.*$'
# NOTE: Update in .pre-commit-config.yaml as well
extend-exclude = "^.*\\b(migrations)\\b.*$ (__pycache__|.*snap_test_.*\\.py|.+/+.+/+migrations/+.*)"

[tool.isort]
profile = "black"
multi_line_output = 3
# NOTE: Update in .pre-commit-config.yaml as well
skip = [
"**/__pycache__",
"**/snap_test_*.py",
".venv/",
"legacy/",
"**/migrations/*.py",
]

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down

0 comments on commit 38d8481

Please sign in to comment.