mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-02-23 15:02:54 +03:00
Move template linting and formatting to ruff
The generated project already uses that, let's be consistent and use it everywhere
This commit is contained in:
parent
a623f7bbc6
commit
ea6ff7907a
4
.flake8
4
.flake8
|
@ -1,4 +0,0 @@
|
||||||
[flake8]
|
|
||||||
exclude = docs
|
|
||||||
max-line-length = 119
|
|
||||||
extend-ignore = E203
|
|
|
@ -25,27 +25,12 @@ repos:
|
||||||
- id: prettier
|
- id: prettier
|
||||||
args: ["--tab-width", "2"]
|
args: ["--tab-width", "2"]
|
||||||
|
|
||||||
- repo: https://github.com/asottile/pyupgrade
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: v3.19.1
|
rev: v0.8.4
|
||||||
hooks:
|
hooks:
|
||||||
- id: pyupgrade
|
- id: ruff
|
||||||
args: [--py312-plus]
|
args: [--fix, --exit-non-zero-on-fix]
|
||||||
exclude: hooks/
|
- id: ruff-format
|
||||||
|
|
||||||
- repo: https://github.com/psf/black
|
|
||||||
rev: 24.10.0
|
|
||||||
hooks:
|
|
||||||
- id: black
|
|
||||||
|
|
||||||
- repo: https://github.com/PyCQA/isort
|
|
||||||
rev: 5.13.2
|
|
||||||
hooks:
|
|
||||||
- id: isort
|
|
||||||
|
|
||||||
- repo: https://github.com/PyCQA/flake8
|
|
||||||
rev: 7.1.1
|
|
||||||
hooks:
|
|
||||||
- id: flake8
|
|
||||||
|
|
||||||
- repo: https://github.com/tox-dev/pyproject-fmt
|
- repo: https://github.com/tox-dev/pyproject-fmt
|
||||||
rev: "v2.5.0"
|
rev: "v2.5.0"
|
||||||
|
|
|
@ -58,22 +58,86 @@ docs = [
|
||||||
"sphinx-rtd-theme>=3",
|
"sphinx-rtd-theme>=3",
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.black]
|
[tool.ruff]
|
||||||
line-length = 119
|
target-version = "py312"
|
||||||
target-version = [
|
# Exclude the template content as most files aren't parseable
|
||||||
'py312',
|
extend-exclude = [
|
||||||
|
"{{cookiecutter.project_slug}}/*",
|
||||||
]
|
]
|
||||||
|
|
||||||
# ==== isort ====
|
[tool.ruff.lint]
|
||||||
|
select = [
|
||||||
[tool.isort]
|
"F",
|
||||||
profile = "black"
|
"E",
|
||||||
line_length = 119
|
"W",
|
||||||
known_first_party = [
|
"C90",
|
||||||
"tests",
|
"I",
|
||||||
"scripts",
|
"N",
|
||||||
"hooks",
|
"UP",
|
||||||
|
"YTT",
|
||||||
|
# "ANN", # flake8-annotations: we should support this in the future but 100+ errors atm
|
||||||
|
"ASYNC",
|
||||||
|
"S",
|
||||||
|
"BLE",
|
||||||
|
"FBT",
|
||||||
|
"B",
|
||||||
|
"A",
|
||||||
|
"COM",
|
||||||
|
"C4",
|
||||||
|
"DTZ",
|
||||||
|
"T10",
|
||||||
|
"EM",
|
||||||
|
"EXE",
|
||||||
|
"FA",
|
||||||
|
'ISC',
|
||||||
|
"ICN",
|
||||||
|
"G",
|
||||||
|
'INP',
|
||||||
|
'PIE',
|
||||||
|
"T20",
|
||||||
|
'PYI',
|
||||||
|
'PT',
|
||||||
|
"Q",
|
||||||
|
"RSE",
|
||||||
|
"RET",
|
||||||
|
"SLF",
|
||||||
|
"SLOT",
|
||||||
|
"SIM",
|
||||||
|
"TID",
|
||||||
|
"TCH",
|
||||||
|
"INT",
|
||||||
|
# "ARG", # Unused function argument
|
||||||
|
"PTH",
|
||||||
|
"ERA",
|
||||||
|
"PD",
|
||||||
|
"PGH",
|
||||||
|
"PL",
|
||||||
|
"TRY",
|
||||||
|
"FLY",
|
||||||
|
# "NPY",
|
||||||
|
# "AIR",
|
||||||
|
"PERF",
|
||||||
|
# "FURB",
|
||||||
|
# "LOG",
|
||||||
|
"RUF",
|
||||||
]
|
]
|
||||||
|
ignore = [
|
||||||
|
"S101", # Use of assert detected https://docs.astral.sh/ruff/rules/assert/
|
||||||
|
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
|
||||||
|
"SIM102", # sometimes it's better to nest
|
||||||
|
"UP038", # Checks for uses of isinstance/issubclass that take a tuple
|
||||||
|
# of types for comparison.
|
||||||
|
# Deactivated because it can make the code slow:
|
||||||
|
# https://github.com/astral-sh/ruff/issues/7871
|
||||||
|
]
|
||||||
|
# The fixes in extend-unsafe-fixes will require
|
||||||
|
# provide the `--unsafe-fixes` flag when fixing.
|
||||||
|
extend-unsafe-fixes = [
|
||||||
|
"UP038",
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.ruff.lint.isort]
|
||||||
|
force-single-line = true
|
||||||
|
|
||||||
# ==== pytest ====
|
# ==== pytest ====
|
||||||
|
|
||||||
|
|
4
tox.ini
4
tox.ini
|
@ -5,7 +5,3 @@ envlist = py312,black-template
|
||||||
[testenv]
|
[testenv]
|
||||||
passenv = AUTOFIXABLE_STYLES
|
passenv = AUTOFIXABLE_STYLES
|
||||||
commands = pytest -n auto {posargs:./tests}
|
commands = pytest -n auto {posargs:./tests}
|
||||||
|
|
||||||
[testenv:black-template]
|
|
||||||
deps = black
|
|
||||||
commands = black --check hooks tests docs scripts
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user