mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-22 01:26:57 +03:00
Update ruff to 0.6.0 (#5300)
* Update ruff from 0.5.7 to 0.6.0 * Update ruff from 0.5.7 to 0.6.0 * Update Ruff pre-commit hook * Update pytest style to match update Ruff rules * Switch Ruff setting from exclude to extend-exclude * Omit default Ruff settings --------- Co-authored-by: Bruno Alla <alla.brunoo@gmail.com>
This commit is contained in:
parent
a97d2b8b66
commit
dc0a511353
|
@ -4,7 +4,7 @@ binaryornot==0.4.4
|
|||
|
||||
# Code quality
|
||||
# ------------------------------------------------------------------------------
|
||||
ruff==0.5.7
|
||||
ruff==0.6.0
|
||||
django-upgrade==1.20.0
|
||||
djlint==1.34.1
|
||||
pre-commit==3.8.0
|
||||
|
|
|
@ -35,7 +35,7 @@ repos:
|
|||
|
||||
# Run the Ruff linter.
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.5.7
|
||||
rev: v0.6.0
|
||||
hooks:
|
||||
# Linter
|
||||
- id: ruff
|
||||
|
|
|
@ -59,36 +59,12 @@ indent_size = 2
|
|||
indent_size = 2
|
||||
|
||||
[tool.ruff]
|
||||
# Exclude a variety of commonly ignored directories.
|
||||
exclude = [
|
||||
".bzr",
|
||||
".direnv",
|
||||
".eggs",
|
||||
".git",
|
||||
".git-rewrite",
|
||||
".hg",
|
||||
".mypy_cache",
|
||||
".nox",
|
||||
".pants.d",
|
||||
".pytype",
|
||||
".ruff_cache",
|
||||
".svn",
|
||||
".tox",
|
||||
".venv",
|
||||
"__pypackages__",
|
||||
"_build",
|
||||
"buck-out",
|
||||
"build",
|
||||
"dist",
|
||||
"node_modules",
|
||||
"venv",
|
||||
"*/migrations/*.py",
|
||||
"staticfiles/*"
|
||||
]
|
||||
# Same as Django: https://github.com/cookiecutter/cookiecutter-django/issues/4792.
|
||||
line-length = 88
|
||||
indent-width = 4
|
||||
target-version = "py312"
|
||||
# Exclude a variety of commonly ignored directories.
|
||||
extend-exclude = [
|
||||
"*/migrations/*.py",
|
||||
"staticfiles/*",
|
||||
]
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = [
|
||||
|
@ -145,33 +121,22 @@ select = [
|
|||
"PERF",
|
||||
# "FURB",
|
||||
# "LOG",
|
||||
"RUF"
|
||||
"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
|
||||
"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
|
||||
]
|
||||
# Allow fix for all enabled rules (when `--fix`) is provided.
|
||||
fixable = ["ALL"]
|
||||
unfixable = []
|
||||
# The fixes in extend-unsafe-fixes will require
|
||||
# provide the `--unsafe-fixes` flag when fixing.
|
||||
extend-unsafe-fixes = [
|
||||
"UP038"
|
||||
"UP038",
|
||||
]
|
||||
# Allow unused variables when underscore-prefixed.
|
||||
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
|
||||
|
||||
[tool.ruff.format]
|
||||
quote-style = "double"
|
||||
indent-style = "space"
|
||||
skip-magic-trailing-comma = false
|
||||
line-ending = "auto"
|
||||
|
||||
[tool.ruff.lint.isort]
|
||||
force-single-line = true
|
||||
|
|
|
@ -28,7 +28,7 @@ sphinx-autobuild==2024.4.16 # https://github.com/GaretJax/sphinx-autobuild
|
|||
|
||||
# Code quality
|
||||
# ------------------------------------------------------------------------------
|
||||
ruff==0.5.7 # https://github.com/astral-sh/ruff
|
||||
ruff==0.6.0 # https://github.com/astral-sh/ruff
|
||||
coverage==7.6.1 # https://github.com/nedbat/coveragepy
|
||||
djlint==1.34.1 # https://github.com/Riverside-Healthcare/djLint
|
||||
pre-commit==3.8.0 # https://github.com/pre-commit/pre-commit
|
||||
|
|
|
@ -9,6 +9,6 @@ def _media_storage(settings, tmpdir) -> None:
|
|||
settings.MEDIA_ROOT = tmpdir.strpath
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def user(db) -> User:
|
||||
return UserFactory()
|
||||
|
|
|
@ -56,7 +56,7 @@ class TestUserAdmin:
|
|||
response = admin_client.get(url)
|
||||
assert response.status_code == HTTPStatus.OK
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def _force_allauth(self, settings):
|
||||
settings.DJANGO_ADMIN_FORCE_ALLAUTH = True
|
||||
# Reload the admin module to apply the setting change
|
||||
|
@ -65,7 +65,7 @@ class TestUserAdmin:
|
|||
with contextlib.suppress(admin.sites.AlreadyRegistered): # type: ignore[attr-defined]
|
||||
reload(users_admin)
|
||||
|
||||
@pytest.mark.django_db()
|
||||
@pytest.mark.django_db
|
||||
@pytest.mark.usefixtures("_force_allauth")
|
||||
def test_allauth_login(self, rf, settings):
|
||||
request = rf.get("/fake-url")
|
||||
|
|
|
@ -6,7 +6,7 @@ from {{ cookiecutter.project_slug }}.users.models import User
|
|||
|
||||
|
||||
class TestUserViewSet:
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def api_rf(self) -> APIRequestFactory:
|
||||
return APIRequestFactory()
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ from django.core.management import call_command
|
|||
from {{ cookiecutter.project_slug }}.users.models import User
|
||||
|
||||
|
||||
@pytest.mark.django_db()
|
||||
@pytest.mark.django_db
|
||||
class TestUserManager:
|
||||
def test_create_user(self):
|
||||
user = User.objects.create_user(
|
||||
|
@ -37,7 +37,7 @@ class TestUserManager:
|
|||
assert user.username is None
|
||||
|
||||
|
||||
@pytest.mark.django_db()
|
||||
@pytest.mark.django_db
|
||||
def test_createsuperuser_command():
|
||||
"""Ensure createsuperuser command works with our custom manager."""
|
||||
out = StringIO()
|
||||
|
|
|
@ -10,7 +10,7 @@ def test_swagger_accessible_by_admin(admin_client):
|
|||
assert response.status_code == HTTPStatus.OK
|
||||
|
||||
|
||||
@pytest.mark.django_db()
|
||||
@pytest.mark.django_db
|
||||
def test_swagger_ui_not_accessible_by_normal_user(client):
|
||||
url = reverse("api-docs")
|
||||
response = client.get(url)
|
||||
|
|
Loading…
Reference in New Issue
Block a user