Skip to content

Commit

Permalink
updated pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
rsnodgrass committed May 23, 2024
1 parent 46d4d8b commit 1416d01
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 18 deletions.
16 changes: 14 additions & 2 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# auto-update pre-commit versions (if > 1 week)
if which runonce &> /dev/null; then
if [ which runonce &> /dev/null ]; then
DIR=`basename $(pwd)`

# install any missing requirements
if [ -d .venv ]; then
if [ -f requirements.txt ]; then
runonce -b -n $DIR uv pip install -r requirements.txt
fi

if [ -f requirements-dev.txt ]; then
runonce -b -n $DIR uv pip install -r requirements-dev.txt
fi
fi

# auto-update pre-commit versions (if > 1 week)
runonce -b -n $DIR -d 7 pre-commit autoupdate
fi
47 changes: 31 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/psf/black
rev: 24.3.0
- id: trailing-whitespace
- id: end-of-file-fixer

# isort - sort import statements
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: black
args: [--config=pyproject.toml]
- repo: https://github.com/hadialqattan/pycln
rev: v2.4.0
- id: isort
files: \.(py)$
args: [--settings-path=pyproject.toml] # ["--profile", "black" ]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.4
hooks:
- id: pycln
args: [--config=pyproject.toml]
#- repo: https://github.com/charliermarsh/ruff-pre-commit
# rev: 'v0.0.262'
# hooks:
# - id: ruff
- id: ruff
args: [ --fix ] # run linter
- id: ruff-format # run formatter


#### OPTIONAL: for keeping syntax more current

- repo: https://github.com/asottile/pyupgrade
rev: v3.15.2
hooks:
- id: pyupgrade
args: [--py311-plus] # NOTE: SET TO HOME ASSISTANT VERSION

- repo: https://github.com/dosisod/refurb
rev: v2.0.0
hooks:
- id: refurb # NOTE: Update pyproject.toml to match HA Python version
18 changes: 18 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[tool.isort]
force_to_top = [ "logging" ]
balanced_wrapping = true

[tool.ruff]
line-length = 88
indent-width = 4

[tool.ruff.format]
quote-style = "single" # Use a single quote instead of double

[tool.pycln]
all = true

[tool.refurb]
python_version = "3.11"
quiet = true
ignore = [ "FURB184" ]

0 comments on commit 1416d01

Please sign in to comment.