Skip to content

Commit

Permalink
Add pre-commit hooks for tox.ini and pyproject.toml (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
flaeppe authored Jan 4, 2024
1 parent c9a5d9c commit fd7c9fc
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 50 deletions.
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,21 @@ repos:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-yaml
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: debug-statements
- id: detect-private-key
- repo: https://github.com/tox-dev/tox-ini-fmt
rev: "1.3.1"
hooks:
- id: tox-ini-fmt
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "1.5.3"
hooks:
- id: pyproject-fmt
additional_dependencies: ["tox>=4.9"]
- repo: https://github.com/adamchainz/django-upgrade
rev: 1.13.0
hooks:
Expand Down
28 changes: 15 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[build-system]
requires = ["setuptools>=67.3.2", "wheel"]
build-backend = "setuptools.build_meta"
requires = [
"setuptools>=67.3.2",
"wheel",
]

[tool.black]
line-length = 88
Expand Down Expand Up @@ -88,6 +91,17 @@ exclude_lines = [
"if TYPE_CHECKING:",
]

[[tool.mypy.overrides]]
module = [
"*.migrations.*",
]
ignore_errors = true

[[tool.mypy.overrides]]
module = [
"parameterized.*",
]
ignore_missing_imports = true
[tool.mypy]
python_version = "3.10"
pretty = true
Expand All @@ -114,15 +128,3 @@ plugins = ["mypy_django_plugin.main"]

[tool.django-stubs]
django_settings_module = "tests.settings"

[[tool.mypy.overrides]]
module = [
"*.migrations.*",
]
ignore_errors = true

[[tool.mypy.overrides]]
module = [
"parameterized.*",
]
ignore_missing_imports = true
79 changes: 42 additions & 37 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,60 +1,65 @@
[tox]
envlist =
django42-py{312,311,310,39}
django41-py{ 311,310,39}
django40-py{ 311,310,39}
django32-py{ 310,39}
requires =
tox>=4.2
env_list =
django42-py{312, 311, 310, 39}
django41-py{311, 310, 39}
django40-py{311, 310, 39}
django32-py{310, 39}
mypy
check-migrations
skipsdist = true

[pytest]
django_find_project = false
pythonpath = .
no_package = true

[testenv]
passenv = TERM
deps =
.[test]
django_main: {[django]main}
django32: {[django]3-2-x}
django40: {[django]4-0-x}
django41: {[django]4-1-x}
django42: {[django]4-2-x}
django32: {[django]3-2-x}
django_main: {[django]main}
commands = pytest --ds=tests.settings --cov --no-cov-on-fail --cov-report xml --cov-report term-missing {posargs}
usedevelop = false

[django]
main =
https://github.com/django/django/tarball/main
4-2-x =
Django>=4.2,<5.0
4-1-x =
Django>=4.1,<4.2
4-0-x =
Django>=4.0,<4.1
3-2-x =
Django>=3.2,<4.0
pass_env =
TERM
commands =
pytest --ds=tests.settings --cov --no-cov-on-fail --cov-report xml --cov-report term-missing {posargs}

[testenv:mypy]
deps =
.[test]
mypy
{[django]3-2-x}
.[test]
django-stubs
commands = mypy --strict src/ tests/
mypy
commands =
mypy --strict src/ tests/

[testenv:check-migrations]
setenv =
PYTHONPATH={toxinidir}
DJANGO_SETTINGS_MODULE=tests.settings
deps =
.[test]
{[django]3-2-x}
commands = django-admin makemigrations --check --dry-run
.[test]
set_env =
DJANGO_SETTINGS_MODULE = tests.settings
PYTHONPATH = {toxinidir}
commands =
django-admin makemigrations --check --dry-run

[testenv:dev]
package = editable
deps =
.[test]
{[django]3-2-x}
usedevelop = true
.[test]

[pytest]
django_find_project = false
pythonpath = .

[django]
main =
https://github.com/django/django/tarball/main
4-2-x =
Django>=4.2,<5.0
4-1-x =
Django>=4.1,<4.2
4-0-x =
Django>=4.0,<4.1
3-2-x =
Django>=3.2,<4.0

0 comments on commit fd7c9fc

Please sign in to comment.