Skip to content

Commit

Permalink
Add pre-commit for testing style
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindeide committed Nov 29, 2023
1 parent 895358b commit d975635
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ jobs:
- name: Add matching rule
run: echo ::add-matcher::.github/flake8-matcher.json

- name: Run ruff
- name: Run style check
if: ${{ always() }}
run: |
ruff check .
- name: Run black
if: ${{ always() }}
uses: psf/black@stable
pre-commit run --all-files --show-diff-on-failure
19 changes: 19 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
hooks:
- id: check-json
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
hooks:
- id: ruff
args: [ --fix ]

- repo: https://github.com/ambv/black
rev: 23.11.0
hooks:
- id: black
13 changes: 6 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ dev = [
]
style = [
"cmake-format",
"black",
"ruff",
"pre-commit",
]
types = [
"mypy",
Expand Down Expand Up @@ -161,7 +160,7 @@ write_to = "src/ert/shared/version.py"
src = ["src"]
select = [
"W", # pycodestyle
"I", # isort
"I", # isort
"B", # flake-8-bugbear
"SIM", # flake-8-simplify
"F", # pyflakes
Expand All @@ -170,15 +169,15 @@ select = [
line-length = 88
ignore = ["PLW2901", # redefined-loop-name
"PLR2004", # magic-value-comparison
"PLR0915", # too-many-statements
"PLR0912", # too-many-branches
"PLR5501", # collapsible-else-if
"PLR0915", # too-many-statements
"PLR0912", # too-many-branches
"PLR5501", # collapsible-else-if
"PLR0911", # too-many-return-statements
]

[tool.ruff.extend-per-file-ignores]
"tests/*" = [
"F401", # unused-import,
"F401", # unused-import,
"PLW0603" # global-statement
]
"src/ert/dark_storage/json_schema/__init__.py" = ["F401"]
Expand Down

0 comments on commit d975635

Please sign in to comment.