Add pre-commit hook and use in CI.

This commit is contained in:
David Wobrock authored and David Wobrock committed 2022-12-26 16:26:24 +01:00
1 parent 2ee7dac3b3
commit f86e0622a5
8 files changed
+53 -27

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-case-conflict
- id: check-json
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: forbid-submodules
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
args:
- "--max-line-length=88"
exclude: ^tests/
- repo: https://github.com/pycqa/isort
rev: 5.11.4
hooks:
- id: isort
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
hooks:
- id: mypy
additional_dependencies:
- types-toml==0.10.8.1
args:
- "--ignore-missing-imports"
exclude: ^tests/
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.194
hooks:
- id: ruff
args:
- "--line-length=88"
exclude: ^tests/
+2 -1
View File
@@ -11,7 +11,8 @@ The crash is a sign to double-check the migration. But if you are certain the mi
- Drop support for Django 2.2 - Drop support for Django 2.2
- Internally rename "migration tests" to "migration checks" - Internally rename "migration tests" to "migration checks"
- Add dataclasses internally instead of custom dicts - Add dataclasses internally instead of custom dicts
- Add type checking using `mypy` - Use pre-commit hooks instead for linting
- Add type checking using `mypy` and `ruff`
## 4.1.0 ## 4.1.0
-1
View File
@@ -6,4 +6,3 @@ A small note on how the linter is usually published to PyPi:
- `pip install wheel twine` - `pip install wheel twine`
- `python3 setup.py sdist bdist_wheel --universal` - `python3 setup.py sdist bdist_wheel --universal`
- `twine upload dist/django_migration_linter-X.Y.Z-py3-none-any.whl dist/django-migration-linter-X.Y.Z.tar.gz` - `twine upload dist/django_migration_linter-X.Y.Z-py3-none-any.whl dist/django-migration-linter-X.Y.Z.tar.gz`
+1 -1
View File
@@ -11,4 +11,4 @@ You can either tweak the ``tests/test_project/settings.py`` file to get your DB
## Database setup ## Database setup
By default, the test Django project in the repository has multiple databases configured in order to make the CI tests work. By default, the test Django project in the repository has multiple databases configured in order to make the CI tests work.
Do not hesitate to modify [the configured test databases](../../tests/test_project/settings.py). Do not hesitate to modify [the configured test databases](../../tests/test_project/settings.py).
+1 -1
View File
@@ -2,7 +2,7 @@
## Command line usage ## Command line usage
The linter is installed as a Django app and is integrated through the Django management command system. The linter is installed as a Django app and is integrated through the Django management command system.
`python manage.py lintmigrations [app_label] [migration_name]` `python manage.py lintmigrations [app_label] [migration_name]`
-6
View File
@@ -1,6 +0,0 @@
flake8==6.0.0
black==22.12.0
isort==5.11.4
mypy==0.991
types-toml==0.10.8.1
ruff==0.0.194
-9
View File
@@ -1,9 +1,3 @@
[flake8]
max-line-length = 88
[ruff]
line-length = 88
[isort] [isort]
multi_line_output = 3 multi_line_output = 3
include_trailing_comma = True include_trailing_comma = True
@@ -13,6 +7,3 @@ ensure_newline_before_comments = True
line_length = 88 line_length = 88
add_imports = add_imports =
from __future__ import annotations from __future__ import annotations
[mypy]
ignore_missing_imports = True
+2 -8
View File
@@ -26,14 +26,8 @@ deps =
[testenv:lint] [testenv:lint]
basepython = python3.10 basepython = python3.10
deps = deps = pre-commit
-r requirements/dev.txt commands = pre-commit run --all-files --show-diff-on-failure
commands =
flake8 django_migration_linter/
black --check django_migration_linter/ tests/ manage.py setup.py
isort --check-only .
mypy django_migration_linter/
ruff django_migration_linter/
[testenv:coverage] [testenv:coverage]
commands = commands =