mirror of
https://github.com/ae-utbm/sith.git
synced 2026-09-09 14:04:36 +00:00
re-apply ruff TCH rules
This commit is contained in:
+4
-2
@@ -3,7 +3,7 @@ import math
|
||||
import uuid
|
||||
from collections import defaultdict
|
||||
from datetime import date, datetime, timezone
|
||||
from typing import ClassVar
|
||||
from typing import TYPE_CHECKING, ClassVar
|
||||
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from django import forms
|
||||
@@ -11,7 +11,6 @@ from django.conf import settings
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db.models import Exists, OuterRef, Q
|
||||
from django.forms import BaseModelFormSet
|
||||
from django.http import HttpRequest
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.timezone import now
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
@@ -59,6 +58,9 @@ from counter.widgets.ajax_select import (
|
||||
AutoCompleteSelectProduct,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from django.http import HttpRequest
|
||||
|
||||
|
||||
class BillingInfoForm(forms.ModelForm):
|
||||
class Meta:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from collections.abc import Iterable
|
||||
from operator import attrgetter
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.mail import send_mass_mail
|
||||
@@ -13,6 +13,9 @@ from django.utils.translation import gettext as _
|
||||
from core.models import User, UserQuerySet
|
||||
from counter.models import AccountDump, Counter, Customer, Product, Selling
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Iterable
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
"""Effectively dump the inactive users.
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
from typing import TYPE_CHECKING, Callable
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.utils.functional import SimpleLazyObject
|
||||
|
||||
from core.models import User
|
||||
from counter.models import Permanency
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from django.contrib.sessions.backends.base import SessionBase
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
|
||||
from core.models import User
|
||||
|
||||
|
||||
SESSION_PERMANENCES_KEY = "permanence_ids"
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
# Generated by Django 4.2.17 on 2024-12-08 13:30
|
||||
from operator import attrgetter
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
from django.db.migrations.state import StateApps
|
||||
from django.db.models import Count
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from django.db.migrations.state import StateApps
|
||||
|
||||
|
||||
def delete_duplicates(apps: StateApps, schema_editor):
|
||||
"""Delete cards of users with more than one student cards.
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
# Generated by Django 4.2.17 on 2024-12-15 17:53
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.db.migrations.state import StateApps
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from django.db.migrations.state import StateApps
|
||||
|
||||
|
||||
def move_priority_to_order(apps: StateApps, schema_editor):
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
# Generated by Django 5.2.8 on 2025-11-19 17:59
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.db.migrations.state import StateApps
|
||||
from django.db.models import Case, When
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from django.db.migrations.state import StateApps
|
||||
|
||||
|
||||
def migrate_selling_payment_method(apps: StateApps, schema_editor):
|
||||
# 0 <=> SITH_ACCOUNT is the default value, so no need to migrate it
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
# Generated by Django 5.2.8 on 2026-02-10 15:40
|
||||
from operator import attrgetter
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import django.utils.timezone
|
||||
from django.db import migrations, models
|
||||
from django.db.migrations.state import StateApps
|
||||
from django.db.models import OuterRef, Subquery
|
||||
|
||||
from counter.models import Selling
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from django.db.migrations.state import StateApps
|
||||
|
||||
|
||||
def apply_product_history_dates(apps: StateApps, schema_editor):
|
||||
"""Approximate a posteriori the value of created_at and updated_at."""
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
# Generated by Django 5.2.11 on 2026-02-18 13:30
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
from django.db.migrations.state import StateApps
|
||||
|
||||
import counter.fields
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from django.db.migrations.state import StateApps
|
||||
|
||||
|
||||
def migrate_prices(apps: StateApps, schema_editor):
|
||||
Product = apps.get_model("counter", "Product")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from collections.abc import Iterable
|
||||
from datetime import timedelta
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import freezegun
|
||||
import pytest
|
||||
@@ -17,6 +17,9 @@ from counter.management.commands.dump_warning_mail import Command as WarningComm
|
||||
from counter.models import AccountDump, Customer, Refilling, Selling
|
||||
from subscription.models import Subscription
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Iterable
|
||||
|
||||
|
||||
class TestAccountDump(TestCase):
|
||||
@classmethod
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import json
|
||||
from datetime import timedelta
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
from django.conf import settings
|
||||
from django.test import Client
|
||||
from django.urls import reverse
|
||||
from django.utils.timezone import now
|
||||
from django_celery_beat.models import ClockedSchedule
|
||||
@@ -18,6 +18,9 @@ from counter.forms import (
|
||||
)
|
||||
from counter.models import Product, ProductType, ScheduledProductAction
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from django.test import Client
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_edit_product(client: Client):
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
from dataclasses import asdict, dataclass
|
||||
from datetime import timedelta
|
||||
from decimal import Decimal
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
from bs4 import BeautifulSoup
|
||||
@@ -22,7 +23,6 @@ from dateutil.relativedelta import relativedelta
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import Permission, make_password
|
||||
from django.contrib.messages import DEFAULT_LEVELS, get_messages
|
||||
from django.http import HttpResponse
|
||||
from django.shortcuts import resolve_url
|
||||
from django.test import Client, TestCase
|
||||
from django.urls import reverse
|
||||
@@ -48,6 +48,9 @@ from counter.models import (
|
||||
Selling,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from django.http import HttpResponse
|
||||
|
||||
|
||||
def set_age(user: User, age: int):
|
||||
user.date_of_birth = localdate().replace(year=localdate().year - age)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from datetime import date, datetime
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from django.contrib.auth.models import Permission
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.test import Client
|
||||
from django.urls import reverse
|
||||
from django.utils.timezone import now
|
||||
from model_bakery import baker
|
||||
@@ -16,6 +16,9 @@ from counter.baker_recipes import sale_recipe
|
||||
from counter.forms import InvoiceCallForm
|
||||
from counter.models import Customer, InvoiceCall, Selling
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from django.test import Client
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
from django.conf import settings
|
||||
from django.test import Client
|
||||
from django.urls import reverse
|
||||
from model_bakery import baker, seq
|
||||
|
||||
@@ -8,6 +9,9 @@ from core.baker_recipes import board_user, subscriber_user
|
||||
from core.models import Group, User
|
||||
from counter.models import ProductType
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from django.test import Client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def product_types(db) -> list[ProductType]:
|
||||
|
||||
+4
-1
@@ -1,8 +1,11 @@
|
||||
from typing import TYPE_CHECKING
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from django.http import HttpRequest
|
||||
from django.urls import resolve
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from django.http import HttpRequest
|
||||
|
||||
|
||||
def is_logged_in_counter(request: HttpRequest) -> bool:
|
||||
"""Check if the request is sent from a device logged to a counter.
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#
|
||||
#
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.mixins import PermissionRequiredMixin
|
||||
@@ -22,7 +24,6 @@ from django.utils.translation import gettext_lazy as _
|
||||
from django.views.generic import DetailView, ListView
|
||||
from django.views.generic.edit import BaseFormView, UpdateView
|
||||
|
||||
from core.models import User
|
||||
from counter.forms import CashSummaryFormBase
|
||||
from counter.models import (
|
||||
CashRegisterSummary,
|
||||
@@ -35,6 +36,9 @@ from counter.views.mixins import (
|
||||
CounterTabsMixin,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.models import User
|
||||
|
||||
|
||||
class CashRegisterSummaryForm(forms.Form):
|
||||
"""Provide the cash summary form."""
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#
|
||||
import random
|
||||
from collections import defaultdict
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from django.contrib import messages
|
||||
from django.core.exceptions import PermissionDenied
|
||||
@@ -22,14 +23,11 @@ from django.db.models import Q
|
||||
from django.http import Http404
|
||||
from django.shortcuts import get_object_or_404, redirect, resolve_url
|
||||
from django.urls import reverse
|
||||
from django.utils.safestring import SafeString
|
||||
from django.utils.translation import gettext as _
|
||||
from django.views.generic import CreateView, FormView
|
||||
from django.views.generic.detail import SingleObjectMixin
|
||||
from ninja.main import HttpRequest
|
||||
|
||||
from core.auth.mixins import CanViewMixin
|
||||
from core.models import User
|
||||
from core.views.mixins import FragmentMixin, UseFragmentsMixin
|
||||
from counter.forms import BasketForm, RefillForm
|
||||
from counter.models import (
|
||||
@@ -44,6 +42,12 @@ from counter.utils import is_logged_in_counter
|
||||
from counter.views.mixins import CounterTabsMixin
|
||||
from counter.views.student_card import StudentCardFormFragment
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from django.utils.safestring import SafeString
|
||||
from ninja.main import HttpRequest
|
||||
|
||||
from core.models import User
|
||||
|
||||
|
||||
def get_operator(request: HttpRequest, counter: Counter, customer: Customer) -> User:
|
||||
if counter.type != "BAR":
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#
|
||||
#
|
||||
from datetime import timedelta
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import PermissionDenied
|
||||
@@ -21,7 +22,6 @@ from django.http import HttpRequest, HttpResponseRedirect
|
||||
from django.shortcuts import redirect
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from django.utils.safestring import SafeString
|
||||
from django.views.decorators.http import require_POST
|
||||
from django.views.generic import DetailView
|
||||
from django.views.generic.detail import SingleObjectMixin
|
||||
@@ -35,6 +35,9 @@ from counter.models import Counter, Permanency
|
||||
from counter.utils import is_logged_in_counter
|
||||
from counter.views.mixins import CounterTabsMixin
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from django.utils.safestring import SafeString
|
||||
|
||||
|
||||
class CounterLoginFragment(FragmentMixin, SingleObjectMixin, FormView):
|
||||
model = Counter
|
||||
|
||||
@@ -13,11 +13,12 @@
|
||||
#
|
||||
#
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.http import Http404, HttpRequest, HttpResponse
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.urls import reverse
|
||||
from django.utils.safestring import SafeString
|
||||
from django.utils.translation import gettext as _
|
||||
from django.views.generic.edit import DeleteView, FormView
|
||||
|
||||
@@ -27,6 +28,9 @@ from counter.forms import StudentCardForm
|
||||
from counter.models import Customer, StudentCard
|
||||
from counter.utils import is_logged_in_counter
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from django.utils.safestring import SafeString
|
||||
|
||||
|
||||
class StudentCardDeleteView(DeleteView):
|
||||
"""View used to delete a card from a user. This is a fragment view !"""
|
||||
|
||||
Reference in New Issue
Block a user