Skip to content

Commit

Permalink
Add pre-commit, style linting with ruff
Browse files Browse the repository at this point in the history
Again, mostly copied from the approach used in
flask-debugtoolbar.
  • Loading branch information
wlach committed May 20, 2024
1 parent d160059 commit ac3ef4b
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 2 deletions.
21 changes: 21 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ci:
autoupdate_schedule: monthly
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.2
hooks:
- id: ruff
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-merge-conflict
exclude: "(codemirror|jquery)"
- id: debug-statements
exclude: "(codemirror|jquery)"
- id: fix-byte-order-marker
exclude: "(codemirror|jquery)"
- id: trailing-whitespace
exclude: "(codemirror|jquery)"
- id: end-of-file-fixer
exclude: "(codemirror|jquery)"
20 changes: 20 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[tool.ruff]
src = ["flask_mail.py"]
fix = true
show-fixes = true
output-format = "full"

[tool.ruff.lint]
select = [
"B", # flake8-bugbear
"E", # pycodestyle error
"F", # pyflakes
"I", # isort
"UP", # pyupgrade
"W", # pycodestyle warning
]
ignore-init-module-imports = true

[tool.ruff.lint.isort]
force-single-line = true
order-by-type = false
1 change: 1 addition & 0 deletions requirements/dev.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
-r tests.txt
tox
pre-commit
17 changes: 16 additions & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#
cachetools==5.3.3
# via tox
cfgv==3.4.0
# via pre-commit
chardet==5.2.0
# via tox
colorama==0.4.6
Expand All @@ -20,12 +22,16 @@ filelock==3.14.0
# via
# tox
# virtualenv
identify==2.5.36
# via pre-commit
iniconfig==2.0.0
# via
# -r tests.txt
# pytest
mock==5.1.0
# via -r tests.txt
nodeenv==1.8.0
# via pre-commit
packaging==24.0
# via
# -r tests.txt
Expand All @@ -41,10 +47,14 @@ pluggy==1.5.0
# -r tests.txt
# pytest
# tox
pre-commit==3.5.0
# via -r dev.in
pyproject-api==1.6.1
# via tox
pytest==8.2.1
# via -r tests.txt
pyyaml==6.0.1
# via pre-commit
speaklater==1.3
# via -r tests.txt
tomli==2.0.1
Expand All @@ -56,4 +66,9 @@ tomli==2.0.1
tox==4.15.0
# via -r dev.in
virtualenv==20.26.2
# via tox
# via
# pre-commit
# tox

# The following packages are considered to be unsafe in a requirements file:
# setuptools
2 changes: 1 addition & 1 deletion requirements/tests.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
mock
pytest
speaklater
speaklater
12 changes: 12 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
envlist =
py3{12,11,10,9,8}
minimal
style
skip_missing_interpreters = true

[testenv]
Expand All @@ -17,6 +18,17 @@ commands = pytest -v --tb=short --basetemp={envtmpdir} tests.py
deps =
commands = python -c "from flask_mail import Mail"

[testenv:style]
deps = pre-commit
skip_install = true
commands = pre-commit run --all-files

[testenv:update-pre_commit]
labels = update
deps = pre-commit
skip_install = true
commands = pre-commit autoupdate -j4

[testenv:update-requirements]
base_python = 3.8
labels = update
Expand Down

0 comments on commit ac3ef4b

Please sign in to comment.