Apply Ruff's flake8-type-checking (TCH) rules

This commit is contained in:
Adam Goldsmith 2024-08-07 14:09:42 -04:00
parent e348e8fbf5
commit 7b3dfef732
5 changed files with 15 additions and 5 deletions

View File

@ -1,8 +1,8 @@
import datetime import datetime
from typing import TYPE_CHECKING
from django.contrib.auth.mixins import PermissionRequiredMixin from django.contrib.auth.mixins import PermissionRequiredMixin
from django.core.exceptions import BadRequest from django.core.exceptions import BadRequest
from django.core.paginator import Page
from django.db.models import Count, F, FloatField, Q, Window from django.db.models import Count, F, FloatField, Q, Window
from django.db.models.functions import Lead, Trunc from django.db.models.functions import Lead, Trunc
from django.urls import path, reverse_lazy from django.urls import path, reverse_lazy
@ -27,6 +27,9 @@ from .tables import (
UnitTimeTable, UnitTimeTable,
) )
if TYPE_CHECKING:
from django.core.paginator import Page
REPORTS = [] REPORTS = []

View File

@ -1,6 +1,5 @@
import uuid import uuid
from datetime import datetime, timedelta from datetime import datetime, timedelta
from decimal import Decimal
from typing import TYPE_CHECKING, TypedDict from typing import TYPE_CHECKING, TypedDict
import django.core.mail.message import django.core.mail.message
@ -596,6 +595,7 @@ class EventExt(Event):
if TYPE_CHECKING: if TYPE_CHECKING:
from decimal import Decimal
class EventExtAnnotations(TypedDict): class EventExtAnnotations(TypedDict):
meetings: int meetings: int

View File

@ -1,4 +1,4 @@
from collections.abc import Iterable from typing import TYPE_CHECKING
from django.conf import settings from django.conf import settings
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
@ -44,6 +44,9 @@ from .tables import (
WaiverReportTable, WaiverReportTable,
) )
if TYPE_CHECKING:
from collections.abc import Iterable
WIKI_URL = settings.WIKI_URL WIKI_URL = settings.WIKI_URL

View File

@ -80,6 +80,7 @@ select = [
"PIE", "PIE",
"LOG", "LOG",
"RSE", "RSE",
"TCH",
] ]
ignore = ["ISC001"] ignore = ["ISC001"]

View File

@ -1,7 +1,6 @@
from __future__ import annotations from __future__ import annotations
from collections.abc import Iterable from typing import TYPE_CHECKING
from datetime import datetime
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.db import models from django.db import models
@ -10,6 +9,10 @@ from django.utils import timezone
from model_utils.managers import InheritanceQuerySetMixin from model_utils.managers import InheritanceQuerySetMixin
if TYPE_CHECKING:
from collections.abc import Iterable
from datetime import datetime
class Resource(models.Model): class Resource(models.Model):
name = models.CharField(max_length=256) name = models.CharField(max_length=256)