Skip to content

Commit

Permalink
Introduce pre-commit and ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
amureki committed Aug 7, 2024
1 parent 162b2eb commit 33df5dc
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 21 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,18 @@ jobs:
strategy:
matrix:
lint-command:
- bandit -r . -x ./tests
- black --check --diff .
- flake8 .
- isort --check-only --diff .
- pydocstyle .
- ruff check --output-format=github .
- djlint emark --reformat
steps:
- uses: actions/checkout@v4
- run: sudo apt install -y gettext
- uses: actions/setup-python@v5
with:
python-version: "3.x"
cache: 'pip'
cache-dependency-path: 'linter-requirements.txt'
- run: python -m pip install -r linter-requirements.txt
cache-dependency-path: 'pyproject.toml'
- run: python -m pip install -e .[lint]
- run: ${{ matrix.lint-command }}

pytest:
Expand Down
37 changes: 37 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: check-merge-conflict
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: name-tests-test
args: ['--pytest-test-first']
- id: no-commit-to-branch
args: [--branch, main]
- id: detect-private-key
- repo: local
hooks:
- id: ruff
name: ruff
language: system
entry: ruff check
types: [python]
args: [--fix, --exit-non-zero-on-fix]

- id: black
name: black
language: system
entry: black
types: [python]

- id: djlint
name: djlint
language: system
entry: djlint
types: [ html ]
args: [ --reformat, --profile, "django" ]
6 changes: 0 additions & 6 deletions linter-requirements.txt

This file was deleted.

40 changes: 31 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ test = [
"pytest-django",
"model_bakery",
]
lint = [
"black==24.8.0",
"pre-commit==3.8.0",
"ruff==0.5.6",
"djlint==1.34.1",
]

[project.urls]
Project-URL = "https://github.com/voiio/emark"
Expand All @@ -69,16 +75,32 @@ omit = ["emark/buildapi.py"]
[tool.coverage.report]
show_missing = true

[tool.isort]
atomic = true
line_length = 88
known_first_party = "emark, tests"
include_trailing_comma = true
default_section = "THIRDPARTY"
combine_as_imports = true
[tool.ruff]
src = ["emark", "tests"]

[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"S", # flake8-bandit
"D", # pydocstyle
"UP", # pyupgrade
"B", # flake8-bugbear
"C", # flake8-comprehensions
]

ignore = ["B904", "D1", "E501", "S101"]

[tool.ruff.lint.isort]
combine-as-imports = true
split-on-trailing-comma = true
section-order = ["future", "standard-library", "third-party", "first-party", "local-folder"]
force-wrap-aliases = true

[tool.pydocstyle]
add_ignore = "D1"
[tool.ruff.lint.pydocstyle]
convention = "google"

[tool.djlint]
profile="django"
Expand Down

0 comments on commit 33df5dc

Please sign in to comment.