From dc0a511353a755c7bd4dd5c8085309984c70332d Mon Sep 17 00:00:00 2001 From: "pyup.io bot" Date: Thu, 15 Aug 2024 08:36:59 -0700 Subject: [PATCH] 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 --- requirements.txt | 2 +- .../.pre-commit-config.yaml | 2 +- {{cookiecutter.project_slug}}/pyproject.toml | 55 ++++--------------- .../requirements/local.txt | 2 +- .../{{cookiecutter.project_slug}}/conftest.py | 2 +- .../users/tests/test_admin.py | 4 +- .../users/tests/test_drf_views.py | 2 +- .../users/tests/test_managers.py | 4 +- .../users/tests/test_swagger.py | 2 +- 9 files changed, 20 insertions(+), 55 deletions(-) diff --git a/requirements.txt b/requirements.txt index dbaefb34..c1214601 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml index d8d69984..7eb2cb37 100644 --- a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml @@ -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 diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index 31e290df..98a883b6 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -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: + # 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 +# 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 diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index a0cb1a5e..4458a35c 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -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 diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/conftest.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/conftest.py index 98efcd75..8d3af053 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/conftest.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/conftest.py @@ -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() diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_admin.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_admin.py index 66555c4e..3e6a41a9 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_admin.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_admin.py @@ -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") diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_views.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_views.py index 955ebe4e..0198b130 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_views.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_views.py @@ -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() diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_managers.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_managers.py index e5e5f5a4..e3553ab4 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_managers.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_managers.py @@ -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() diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_swagger.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_swagger.py index 3081d1f6..5db371db 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_swagger.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_swagger.py @@ -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)