Skip to content

Commit

Permalink
Update ruff to 0.6.0 (#5300)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
pyup-bot and browniebroke authored Aug 15, 2024
1 parent a97d2b8 commit dc0a511
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 53 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 8 additions & 43 deletions {{cookiecutter.project_slug}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,36 +59,12 @@ indent_size = 2
indent_size = 2

[tool.ruff]
target-version = "py312"
# 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",
extend-exclude = [
"*/migrations/*.py",
"staticfiles/*"
"staticfiles/*",
]
# Same as Django: https://github.com/cookiecutter/cookiecutter-django/issues/4792.
line-length = 88
indent-width = 4
target-version = "py312"

[tool.ruff.lint]
select = [
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/requirements/local.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_view_user(self, admin_client):
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
Expand All @@ -65,7 +65,7 @@ def _force_allauth(self, settings):
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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class TestUserViewSet:
@pytest.fixture()
@pytest.fixture
def api_rf(self) -> APIRequestFactory:
return APIRequestFactory()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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(
Expand Down Expand Up @@ -37,7 +37,7 @@ def test_create_superuser_username_ignored(self):
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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit dc0a511

Please sign in to comment.