diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f1d30b75..6dbdcc33 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,7 @@ repos: - id: pyupgrade args: ['--keep-runtime-typing', '--py311-plus'] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.7.1 + rev: v0.8.1 hooks: - id: ruff args: ['--fix', '--exit-non-zero-on-fix'] @@ -57,7 +57,7 @@ repos: - types-setuptools - typing-extensions - repo: https://github.com/PyCQA/pylint - rev: v3.3.1 + rev: v3.3.2 hooks: - id: pylint args: [ @@ -69,7 +69,7 @@ repos: additional_dependencies: - tomli - repo: https://github.com/PyCQA/bandit - rev: 1.7.10 + rev: 1.8.0 hooks: - id: bandit language_version: python3 diff --git a/boxoffice/forms/discount.py b/boxoffice/forms/discount.py index cb5ddeb8..8b9856b6 100644 --- a/boxoffice/forms/discount.py +++ b/boxoffice/forms/discount.py @@ -14,12 +14,12 @@ ) __all__ = [ - 'DiscountPolicyForm', - 'PriceBasedDiscountPolicyForm', - 'DiscountPriceForm', - 'DiscountCouponForm', 'AutomaticDiscountPolicyForm', 'CouponBasedDiscountPolicyForm', + 'DiscountCouponForm', + 'DiscountPolicyForm', + 'DiscountPriceForm', + 'PriceBasedDiscountPolicyForm', ] diff --git a/boxoffice/forms/order.py b/boxoffice/forms/order.py index 9571c009..d4d027a5 100644 --- a/boxoffice/forms/order.py +++ b/boxoffice/forms/order.py @@ -9,7 +9,7 @@ from ..data import codes as gst_codes, indian_states_dict -__all__ = ['LineItemForm', 'BuyerForm', 'OrderSessionForm', 'InvoiceForm'] +__all__ = ['BuyerForm', 'InvoiceForm', 'LineItemForm', 'OrderSessionForm'] def trim(length: int) -> Callable[[str | None], str]: diff --git a/boxoffice/models/discount_policy.py b/boxoffice/models/discount_policy.py index d4999846..a312f2f0 100644 --- a/boxoffice/models/discount_policy.py +++ b/boxoffice/models/discount_policy.py @@ -30,7 +30,7 @@ from .enums import DiscountTypeEnum, LineItemStatus from .user import Organization, User -__all__ = ['DiscountPolicy', 'DiscountCoupon', 'item_discount_policy'] +__all__ = ['DiscountCoupon', 'DiscountPolicy', 'item_discount_policy'] item_discount_policy = sa.Table( diff --git a/boxoffice/models/enums.py b/boxoffice/models/enums.py index d238cd7e..5152685c 100644 --- a/boxoffice/models/enums.py +++ b/boxoffice/models/enums.py @@ -8,15 +8,15 @@ from baseframe import __ __all__ = [ + 'CurrencyEnum', + 'CurrencySymbol', 'DiscountTypeEnum', 'InvoiceStatus', 'LineItemStatus', 'OrderStatus', + 'RazorpayPaymentStatus', 'TransactionMethodEnum', 'TransactionTypeEnum', - 'CurrencyEnum', - 'CurrencySymbol', - 'RazorpayPaymentStatus', ] diff --git a/boxoffice/models/line_item.py b/boxoffice/models/line_item.py index 0bdb6983..8159e3c8 100644 --- a/boxoffice/models/line_item.py +++ b/boxoffice/models/line_item.py @@ -29,7 +29,7 @@ from .enums import LineItemStatus from .user import User -__all__ = ['LineItemTuple', 'LineItem', 'Assignee'] +__all__ = ['Assignee', 'LineItem', 'LineItemTuple'] class LineItemTuple(NamedTuple): diff --git a/boxoffice/models/line_item_discounter.py b/boxoffice/models/line_item_discounter.py index a9bba840..d6271784 100644 --- a/boxoffice/models/line_item_discounter.py +++ b/boxoffice/models/line_item_discounter.py @@ -41,7 +41,7 @@ def get_valid_discounts( return [] ticket = Ticket.query.get(line_items[0].ticket_id) - if ticket is None or not ticket.is_available and not ticket.is_cancellable(): + if ticket is None or (not ticket.is_available and not ticket.is_cancellable()): # Ticket unavailable, no discounts return [] @@ -94,8 +94,12 @@ def apply_discount( ) if ( # pylint: disable=too-many-boolean-expressions ( - policy_coupon.coupon - and self.is_coupon_usable(policy_coupon.coupon, applied_to_count) + ( + policy_coupon.coupon + and self.is_coupon_usable( + policy_coupon.coupon, applied_to_count + ) + ) or policy_coupon.policy.is_automatic ) and discounted_amount > 0 diff --git a/boxoffice/models/ticket.py b/boxoffice/models/ticket.py index 1707f3af..9062d325 100644 --- a/boxoffice/models/ticket.py +++ b/boxoffice/models/ticket.py @@ -31,7 +31,7 @@ from .enums import LineItemStatus from .user import User -__all__ = ['Ticket', 'Price'] +__all__ = ['Price', 'Ticket'] class AvailabilityData(NamedTuple): diff --git a/boxoffice/models/user.py b/boxoffice/models/user.py index aa6c367a..7ed3be57 100644 --- a/boxoffice/models/user.py +++ b/boxoffice/models/user.py @@ -8,7 +8,7 @@ from . import DynamicMapped, Mapped, Model, Query, db, relationship, sa from .utils import HeadersAndDataTuple -__all__ = ['User', 'Organization'] +__all__ = ['Organization', 'User'] class User(UserBase2, Model): diff --git a/boxoffice/models/utils.py b/boxoffice/models/utils.py index 4117adf7..b30943d2 100644 --- a/boxoffice/models/utils.py +++ b/boxoffice/models/utils.py @@ -8,7 +8,7 @@ from . import sa -__all__ = ['HeadersAndDataTuple', 'naive_to_utc', 'get_fiscal_year'] +__all__ = ['HeadersAndDataTuple', 'get_fiscal_year', 'naive_to_utc'] class HeadersAndDataTuple(NamedTuple): diff --git a/boxoffice/views/utils.py b/boxoffice/views/utils.py index aab5c187..b68af378 100644 --- a/boxoffice/views/utils.py +++ b/boxoffice/views/utils.py @@ -121,11 +121,9 @@ def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> BaseResponse: referrer = request.referrer origin = basepath(referrer) if referrer else 'null' - if ( - request.method == 'POST' - and not origin - or origin not in app.config['ALLOWED_ORIGINS'] - ): + if (request.method == 'POST' and not origin) or origin not in app.config[ + 'ALLOWED_ORIGINS' + ]: abort(403) if request.method == 'OPTIONS':