Skip to content

Commit

Permalink
Update our pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Nov 12, 2024
1 parent 8d5a107 commit 05d1594
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 51 deletions.
37 changes: 12 additions & 25 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
exclude: ".yarn/|yarn.lock|\\.min\\.(css|js)$"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-builtin-literals
Expand All @@ -14,40 +14,27 @@ repos:
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/adamchainz/django-upgrade
rev: 1.15.0
rev: 1.22.1
hooks:
- id: django-upgrade
args: [--target-version, "3.2"]
- repo: https://github.com/MarcoGorelli/absolufy-imports
rev: v0.3.1
hooks:
- id: absolufy-imports
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.1.3"
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.7.0"
hooks:
- id: ruff
args: [--unsafe-fixes]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.3
hooks:
- id: prettier
args: [--list-different, --no-semi]
exclude: "^conf/|.*\\.html$"
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.52.0
- repo: https://github.com/biomejs/pre-commit
rev: "v0.5.0"
hooks:
- id: eslint
additional_dependencies:
- eslint
- eslint-config-prettier
- "@babel/core"
- "@babel/eslint-parser"
- "@babel/preset-env"
- id: biome-check
additional_dependencies: ["@biomejs/[email protected]"]
args: [--unsafe]
- repo: https://github.com/tox-dev/pyproject-fmt
rev: 1.3.0
rev: 2.4.3
hooks:
- id: pyproject-fmt
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.15
rev: v0.21
hooks:
- id: validate-pyproject
57 changes: 57 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"organizeImports": {
"enabled": false
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"a11y": {
"noSvgWithoutTitle": "off"
},
"correctness": {
"noUndeclaredVariables": "error",
"noUnusedImports": "error",
"noUnusedVariables": "error",
"useArrayLiterals": "error",
"useHookAtTopLevel": "error"
},
"security": {
"noDangerouslySetInnerHtml": "warn"
},
"style": {
"noParameterAssign": "off",
"useForOf": "warn"
},
"suspicious": {
"noArrayIndexKey": "warn",
"noAssignInExpressions": "off"
}
}
},
"javascript": {
"formatter": {
"semicolons": "asNeeded"
},
"globals": ["django", "CKEDITOR"]
},
"css": {
"formatter": {
"enabled": true
},
"linter": {
"enabled": true
}
},
"json": {
"formatter": {
"enabled": false
}
}
}
2 changes: 1 addition & 1 deletion feincms3_language_sites/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def site_middleware(get_response):
def middleware(request):
request.site = site_for_host(request.get_host())
if request.site is None:
raise DisallowedHost("No configuration found for %r" % request.get_host())
raise DisallowedHost(f"No configuration found for {request.get_host()!r}")

translation.activate(request.site["language_code"])
request.LANGUAGE_CODE = translation.get_language()
Expand Down
39 changes: 18 additions & 21 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ requires = [
name = "feincms3-language-sites"
description = "Multisite support for feincms3"
readme = "README.rst"
license = {text="BSD-3-Clause"}
license = { text = "BSD-3-Clause" }
authors = [
{ name = "Matthias Kestenholz", email = "[email protected]" },
{ name = "Matthias Kestenholz", email = "[email protected]" },
]
requires-python = ">=3.9"
classifiers = [
Expand All @@ -24,6 +24,8 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
"Topic :: Software Development",
"Topic :: Software Development :: Libraries :: Application Frameworks",
Expand All @@ -32,24 +34,28 @@ dynamic = [
"version",
]
dependencies = [
"Django>=3.2",
"django>=3.2",
"feincms3>=5.0a2",
]
[project.optional-dependencies]
tests = [
optional-dependencies.tests = [
"coverage",
"feincms3[all]",
]
[project.urls]
Homepage = "https://github.com/matthiask/feincms3-language-sites/"
urls.Homepage = "https://github.com/matthiask/feincms3-language-sites/"

[tool.hatch.version]
path = "feincms3_language_sites/__init__.py"

[tool.ruff]
target-version = "py39"

fix = true
show-fixes = true
extend-select = [
# pyflakes, pycodestyle
"F", "E", "W",
"F",
"E",
"W",
# mmcabe
"C90",
# isort
Expand Down Expand Up @@ -87,19 +93,10 @@ extend-ignore = [
# No line length errors
"E501",
]
fix = true
show-fixes = true
target-version = "py39"

[tool.ruff.isort]
combine-as-imports = true
lines-after-imports = 2

[tool.ruff.mccabe]
max-complexity = 15

[tool.ruff.per-file-ignores]
"*/migrat*/*" = [
isort.combine-as-imports = true
isort.lines-after-imports = 2
mccabe.max-complexity = 15
per-file-ignores."*/migrat*/*" = [
# Allow using PascalCase model names in migrations
"N806",
# Ignore the fact that migration files are invalid module names
Expand Down
2 changes: 1 addition & 1 deletion tests/testapp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

pages_urlpatterns = (
[
path("", lambda request: HttpResponseRedirect("/%s/" % request.LANGUAGE_CODE)),
path("", lambda request: HttpResponseRedirect(f"/{request.LANGUAGE_CODE}/")),
re_path(r"^(?P<path>[-\w/]+)/$", views.page_detail, name="page"),
path("", views.page_detail, name="root"),
],
Expand Down
4 changes: 1 addition & 3 deletions tests/testapp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@


def page_detail(request, path=None):
page = get_object_or_404(
Page.objects.active(), path=("/%s/" % path) if path else "/"
)
page = get_object_or_404(Page.objects.active(), path=(f"/{path}/") if path else "/")
page.activate_language(request)

return render(
Expand Down

0 comments on commit 05d1594

Please sign in to comment.