Skip to content

Commit

Permalink
Hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Jun 3, 2024
1 parent 4a67e47 commit 86ad0da
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 57 deletions.
34 changes: 13 additions & 21 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.4.0
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-builtin-literals
Expand All @@ -14,43 +14,35 @@ repos:
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/adamchainz/django-upgrade
rev: 1.14.1
rev: 1.16.0
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.0.285"
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.3.2"
hooks:
- id: ruff
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.2
rev: v3.1.0
hooks:
- id: prettier
args: [--list-different, --no-semi]
exclude: "^conf/|.*\\.html$"
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.47.0
hooks:
- id: eslint
additional_dependencies:
- eslint
- eslint-config-prettier
- "@babel/core"
- "@babel/eslint-parser"
- "@babel/preset-env"
- repo: https://github.com/biomejs/pre-commit
rev: "v0.1.0"
hooks:
- id: biome-check
additional_dependencies: ["@biomejs/biome@1.7.3"]
- repo: https://github.com/tox-dev/pyproject-fmt
rev: 0.13.1
rev: 1.7.0
hooks:
- id: pyproject-fmt
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.13
rev: v0.16
hooks:
- id: validate-pyproject
4 changes: 2 additions & 2 deletions plata/payment/modules/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ def order_paid(self, order, payment=None, request=None):

if order.discount_remaining:
logger.info(
"Creating discount for remaining amount {} on"
" order {}".format(order.discount_remaining, order)
f"Creating discount for remaining amount {order.discount_remaining} on"
f" order {order}"
)
discount_model = self.shop.discount_model
try:
Expand Down
1 change: 0 additions & 1 deletion plata/payment/modules/cod.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
Automatically completes every order passed.
"""


import logging

from django.utils import timezone
Expand Down
4 changes: 1 addition & 3 deletions plata/payment/modules/datatrans.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,7 @@ def datatrans_success(self, request):
response_code = response.find("responseCode").text
if response_code not in ("1", "2", "3"):
logger.error(
"IPN: Received response_code {}, could not verify parameters {}".format(
response_code, parameters_repr
)
f"IPN: Received response_code {response_code}, could not verify parameters {parameters_repr}"
)
parameters = None

Expand Down
1 change: 0 additions & 1 deletion plata/payment/modules/ogone.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
}
"""


import locale
import logging
from decimal import Decimal
Expand Down
4 changes: 1 addition & 3 deletions plata/payment/modules/pagseguro.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,7 @@ def psnotify(self, request):
if PAGSEGURO.get("LOG"):
f = open(PAGSEGURO.get("LOG"), "a")
f.write(
"{} - status: {}, ref: {}, code: {}\n".format(
time.ctime(), status, reference, notificationCode
)
f"{time.ctime()} - status: {status}, ref: {reference}, code: {notificationCode}\n"
)
f.close()

Expand Down
1 change: 0 additions & 1 deletion plata/payment/modules/paypal.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
}
"""


import logging
from decimal import Decimal
from urllib.request import urlopen
Expand Down
1 change: 0 additions & 1 deletion plata/payment/modules/postfinance.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
}
"""


import locale
import logging
from decimal import Decimal
Expand Down
1 change: 1 addition & 0 deletions plata/payment/modules/stripe.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
}
"""

import logging

import stripe # official API, see https://stripe.com/docs/api/python
Expand Down
1 change: 0 additions & 1 deletion plata/product/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
It may save you some typing though.
"""


from django.db import models

import plata
Expand Down
1 change: 0 additions & 1 deletion plata/product/stock/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
into account ``items_in_stock``.
"""


from datetime import timedelta

from django.core.exceptions import ValidationError
Expand Down
7 changes: 1 addition & 6 deletions plata/shipping/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,7 @@ def max_size_f(self):
if self.max_3d and self.max_3d < size:
return "%d %s" % (self.max_3d, LENGTH_UNIT)
if d3:
return "{} × {} × {} {}".format(
self.max_length,
self.max_width,
self.max_height,
LENGTH_UNIT,
)
return f"{self.max_length} × {self.max_width} × {self.max_height} {LENGTH_UNIT}"
return "%d %s" % (size, LENGTH_UNIT)

max_size_f.help_text = _(
Expand Down
1 change: 1 addition & 0 deletions plata/shop/ga_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
signals.order_confirmed.connect(ga_tracking.on_order_confirmed)
signals.order_paid.connect(ga_tracking.on_order_paid)
"""

from django.conf import settings
from django.utils.timezone import now
from pyga.requests import Item, Session, Tracker, Transaction, Visitor
Expand Down
12 changes: 6 additions & 6 deletions plata/shop/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,7 @@ def modify_item(
price = product.get_price(currency=self.currency, orderitem=item)
except ObjectDoesNotExist:
logger.warning(
"No price could be found for {} with currency {}".format(
product, self.currency
)
f"No price could be found for {product} with currency {self.currency}"
)

raise ValidationError(
Expand Down Expand Up @@ -694,9 +692,11 @@ def __str__(self):
def save(self, *args, **kwargs):
super().save(*args, **kwargs)
self.order.status = self.status
if self.status == Order.CONFIRMED:
self.order.confirmed = timezone.now()
elif self.status > Order.CONFIRMED and not self.order.confirmed:
if (
self.status == Order.CONFIRMED
or self.status > Order.CONFIRMED
and not self.order.confirmed
):
self.order.confirmed = timezone.now()
elif self.status < Order.CONFIRMED:
# Ensure that the confirmed date is not set
Expand Down
1 change: 0 additions & 1 deletion plata/shop/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def __call__(self, sender, order, **kwargs):
weak=False)
"""


import contextlib
from io import BytesIO

Expand Down
5 changes: 2 additions & 3 deletions tests/testapp/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ def setUp(self):
u.save()

product_model = Product
self.product_admin_url = "/admin/{}/{}/".format(
product_model._meta.app_label,
product_model._meta.model_name,
self.product_admin_url = (
f"/admin/{product_model._meta.app_label}/{product_model._meta.model_name}/"
)

def login(self):
Expand Down
12 changes: 6 additions & 6 deletions tests/testapp/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,9 +770,9 @@ def test_18_amount_discount_incl_tax(self):
def test_20_shipping_discount(self):
"""Test applying discounts to shipping too"""
order_processors = plata.settings.PLATA_ORDER_PROCESSORS[:]
plata.settings.PLATA_ORDER_PROCESSORS[
-2
] = "plata.shop.processors.FixedAmountShippingProcessor"
plata.settings.PLATA_ORDER_PROCESSORS[-2] = (
"plata.shop.processors.FixedAmountShippingProcessor"
)

try:
p1 = self.create_product()
Expand Down Expand Up @@ -847,9 +847,9 @@ def test_22_tax_rounding(self):

def test_23_mixed_tax(self):
order_processors = plata.settings.PLATA_ORDER_PROCESSORS[:]
plata.settings.PLATA_ORDER_PROCESSORS[
-2
] = "plata.shop.processors.FixedAmountShippingProcessor"
plata.settings.PLATA_ORDER_PROCESSORS[-2] = (
"plata.shop.processors.FixedAmountShippingProcessor"
)

try:
p1 = self.create_product(stock=10)
Expand Down

0 comments on commit 86ad0da

Please sign in to comment.