From f027464d0eedce421cfe6eca7756b8e332682c77 Mon Sep 17 00:00:00 2001 From: imperosol Date: Fri, 7 Nov 2025 16:24:28 +0100 Subject: [PATCH] apply new ruff rules --- .pre-commit-config.yaml | 4 ++-- core/models.py | 2 -- counter/models.py | 2 +- counter/tests/test_counter.py | 26 +++++++++++++------------- eboutic/models.py | 2 +- eboutic/tests/test_payment.py | 2 +- subscription/models.py | 2 +- 7 files changed, 19 insertions(+), 21 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4379d91a..08e322ca 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.11.13 + rev: v0.14.4 hooks: - id: ruff-check # just check the code, and print the errors - id: ruff-check # actually fix the fixable errors, but print nothing @@ -14,7 +14,7 @@ repos: - id: biome-check additional_dependencies: ["@biomejs/biome@1.9.4"] - repo: https://github.com/rtts/djhtml - rev: 3.0.7 + rev: 3.0.10 hooks: - id: djhtml name: format templates diff --git a/core/models.py b/core/models.py index 0506364a..bf54a33a 100644 --- a/core/models.py +++ b/core/models.py @@ -1157,8 +1157,6 @@ class QuickUploadImage(models.Model): identifier = str(uuid4()) name = Path(image.name).stem[: cls.IMAGE_NAME_SIZE - 1] file = File(convert_image(image), name=f"{identifier}.webp") - width, height = Image.open(file).size - return cls.objects.create( uuid=identifier, name=name, diff --git a/counter/models.py b/counter/models.py index 1e92612b..f98f3e44 100644 --- a/counter/models.py +++ b/counter/models.py @@ -86,7 +86,7 @@ class CustomerQuerySet(models.QuerySet): .annotate(res=Sum(F("unit_price") * F("quantity"), default=0)) .values("res") ) - return self.update(amount=Coalesce(money_in - money_out, Decimal("0"))) + return self.update(amount=Coalesce(money_in - money_out, Decimal(0))) class Customer(models.Model): diff --git a/counter/tests/test_counter.py b/counter/tests/test_counter.py index 453727a1..af0e07ad 100644 --- a/counter/tests/test_counter.py +++ b/counter/tests/test_counter.py @@ -355,7 +355,7 @@ class TestCounterClick(TestFullClickBase): self.submit_basket(self.barmen, [BasketItem(self.beer.id, 1)]) ).status_code == 302 - assert self.updated_amount(self.barmen) == Decimal("9") + assert self.updated_amount(self.barmen) == Decimal(9) def test_click_tray_price(self): force_refill_user(self.customer, 20) @@ -364,12 +364,12 @@ class TestCounterClick(TestFullClickBase): # Not applying tray price res = self.submit_basket(self.customer, [BasketItem(self.beer_tap.id, 2)]) assert res.status_code == 302 - assert self.updated_amount(self.customer) == Decimal("17") + assert self.updated_amount(self.customer) == Decimal(17) # Applying tray price res = self.submit_basket(self.customer, [BasketItem(self.beer_tap.id, 7)]) assert res.status_code == 302 - assert self.updated_amount(self.customer) == Decimal("8") + assert self.updated_amount(self.customer) == Decimal(8) def test_click_alcool_unauthorized(self): self.login_in_bar() @@ -381,13 +381,13 @@ class TestCounterClick(TestFullClickBase): res = self.submit_basket(user, [BasketItem(self.snack.id, 2)]) assert res.status_code == 302 - assert self.updated_amount(user) == Decimal("7") + assert self.updated_amount(user) == Decimal(7) # Buy product without age limit res = self.submit_basket(user, [BasketItem(self.beer.id, 2)]) assert res.status_code == 200 - assert self.updated_amount(user) == Decimal("7") + assert self.updated_amount(user) == Decimal(7) def test_click_unauthorized_customer(self): self.login_in_bar() @@ -401,7 +401,7 @@ class TestCounterClick(TestFullClickBase): assert resp.status_code == 302 assert resp.url == resolve_url(self.counter) - assert self.updated_amount(user) == Decimal("10") + assert self.updated_amount(user) == Decimal(10) def test_click_user_without_customer(self): self.login_in_bar() @@ -418,7 +418,7 @@ class TestCounterClick(TestFullClickBase): ) assert res.status_code == 302 - assert self.updated_amount(self.customer_old_can_buy) == Decimal("7") + assert self.updated_amount(self.customer_old_can_buy) == Decimal(7) def test_click_wrong_counter(self): self.login_in_bar() @@ -443,7 +443,7 @@ class TestCounterClick(TestFullClickBase): ) assertRedirects(res, self.counter.get_absolute_url()) - assert self.updated_amount(self.customer) == Decimal("10") + assert self.updated_amount(self.customer) == Decimal(10) def test_click_not_connected(self): force_refill_user(self.customer, 10) @@ -455,7 +455,7 @@ class TestCounterClick(TestFullClickBase): ) assert res.status_code == 403 - assert self.updated_amount(self.customer) == Decimal("10") + assert self.updated_amount(self.customer) == Decimal(10) def test_click_product_not_in_counter(self): force_refill_user(self.customer, 10) @@ -463,7 +463,7 @@ class TestCounterClick(TestFullClickBase): res = self.submit_basket(self.customer, [BasketItem(self.stamps.id, 2)]) assert res.status_code == 200 - assert self.updated_amount(self.customer) == Decimal("10") + assert self.updated_amount(self.customer) == Decimal(10) def test_basket_empty(self): force_refill_user(self.customer, 10) @@ -477,7 +477,7 @@ class TestCounterClick(TestFullClickBase): self.submit_basket(self.customer, basket), self.counter.get_absolute_url(), ) - assert self.updated_amount(self.customer) == Decimal("10") + assert self.updated_amount(self.customer) == Decimal(10) def test_click_product_invalid(self): force_refill_user(self.customer, 10) @@ -490,7 +490,7 @@ class TestCounterClick(TestFullClickBase): BasketItem(self.beer.id, None), ]: assert self.submit_basket(self.customer, [item]).status_code == 200 - assert self.updated_amount(self.customer) == Decimal("10") + assert self.updated_amount(self.customer) == Decimal(10) def test_click_not_enough_money(self): force_refill_user(self.customer, 10) @@ -501,7 +501,7 @@ class TestCounterClick(TestFullClickBase): ) assert res.status_code == 200 - assert self.updated_amount(self.customer) == Decimal("10") + assert self.updated_amount(self.customer) == Decimal(10) def test_annotate_has_barman_queryset(self): """Test if the custom queryset method `annotate_has_barman` works as intended.""" diff --git a/eboutic/models.py b/eboutic/models.py index 839f8fec..f0016073 100644 --- a/eboutic/models.py +++ b/eboutic/models.py @@ -242,7 +242,7 @@ class Invoice(models.Model): def validate(self): if self.validated: raise DataError(_("Invoice already validated")) - customer, created = Customer.get_or_create(user=self.user) + customer, _created = Customer.get_or_create(user=self.user) eboutic = Counter.objects.filter(type="EBOUTIC").first() for i in self.items.all(): if i.type_id == settings.SITH_COUNTER_PRODUCTTYPE_REFILLING: diff --git a/eboutic/tests/test_payment.py b/eboutic/tests/test_payment.py index 61893584..dd619169 100644 --- a/eboutic/tests/test_payment.py +++ b/eboutic/tests/test_payment.py @@ -108,7 +108,7 @@ class TestPaymentSith(TestPaymentBase): ) assert Basket.objects.filter(id=self.basket.id).first() is None self.customer.customer.refresh_from_db() - assert self.customer.customer.amount == Decimal("1") + assert self.customer.customer.amount == Decimal(1) sellings = Selling.objects.filter(customer=self.customer.customer).order_by( "quantity" diff --git a/subscription/models.py b/subscription/models.py index e8aa4ff7..3b25a033 100644 --- a/subscription/models.py +++ b/subscription/models.py @@ -78,7 +78,7 @@ class Subscription(models.Model): from counter.models import Customer - customer, _ = Customer.get_or_create(self.member) + Customer.get_or_create(self.member) # Someone who subscribed once will be considered forever # as an old subscriber. self.member.groups.add(settings.SITH_GROUP_OLD_SUBSCRIBERS_ID)