Skip to content

Commit

Permalink
Add pre-commit-workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Nicola Sella <[email protected]>
  • Loading branch information
inknos committed Nov 29, 2024
1 parent d4668d5 commit d2ef131
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: pre-commit
on:
pull_request:
push:
branches: [main]
jobs:
pre-commit:
runs-on: ubuntu-latest
env:
SKIP: no-commit-to-branch
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: |
3.9
3.x
- uses: pre-commit/[email protected]
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.6.0
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
50 changes: 50 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

line-length = 100
[format]
exclude = [
".git",
".venv",
".history",
"build",
"dist",
"docs",
"hack",
]
quote-style = "preserve"
[lint]
select = [
# More stuff here https://docs.astral.sh/ruff/rules/
"F", # Pyflakes
"E", # Pycodestyle Error
"W", # Pycodestyle Warning
"N", # PEP8 Naming
# TODO "UP", # Pyupgrade
# TODO "ANN",
# TODO "S", # Bandit
# "B", # Bugbear
"A", # flake-8-builtins
"YTT", # flake-8-2020
"PLC", # Pylint Convention
"PLE", # Pylint Error
"PLW", # Pylint Warning
]
# Some checks should be enabled for code sanity disabled now
# to avoid changing too many lines
ignore = [
"F821", # TODO Undefined name
"F541", # TODO f-string is missing placeholders
"F401", # TODO Module imported but unused
"F841", # TODO Local variable is assigned to but never used
"E402", # TODO Module level import not at top of file
"E741", # TODO ambiguous variable name
"E722", # TODO do not use bare 'except'
"E501", # TODO line too long
"N818", # TODO Error Suffix in exception name
"N80", # TODO Invalid Name
"ANN10", # Missing type annotation
"PLW2901", # TODO Redefined Loop Name
]
[lint.per-file-ignores]
"podman/tests/*.py" = ["S"]
[lint.flake8-builtins]
builtins-ignorelist = ["copyright", "all"]

0 comments on commit d2ef131

Please sign in to comment.