From 0400fed26ad5e201513782a89683d58602b00809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Hells=C3=A9n?= Date: Sat, 29 Nov 2025 21:49:44 +0100 Subject: [PATCH] Forces all from imports to appear on their own line --- config/urls.py | 6 ++-- pyproject.toml | 1 + twitch/feeds.py | 8 ++++-- twitch/management/commands/import_drops.py | 19 ++++++++++--- twitch/migrations/0001_initial.py | 3 +- twitch/urls.py | 8 ++---- twitch/views.py | 33 ++++++++++++++++------ 7 files changed, 56 insertions(+), 22 deletions(-) diff --git a/config/urls.py b/config/urls.py index e64a6b4..4f091e1 100644 --- a/config/urls.py +++ b/config/urls.py @@ -4,10 +4,12 @@ from typing import TYPE_CHECKING from django.conf import settings from django.conf.urls.static import static -from django.urls import include, path +from django.urls import include +from django.urls import path if TYPE_CHECKING: - from django.urls.resolvers import URLPattern, URLResolver + from django.urls.resolvers import URLPattern + from django.urls.resolvers import URLResolver urlpatterns: list[URLResolver] | list[URLPattern | URLResolver] = [ # type: ignore[assignment] path(route="", view=include("twitch.urls", namespace="twitch")), diff --git a/pyproject.toml b/pyproject.toml index b6ee99b..f409b62 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,6 +35,7 @@ lint.unfixable = ["F841"] lint.pydocstyle.convention = "google" lint.isort.required-imports = ["from __future__ import annotations"] +lint.isort.force-single-line = true lint.ignore = [ "ANN002", # Checks that function *args arguments have type annotations. diff --git a/twitch/feeds.py b/twitch/feeds.py index 9f593f8..2e1afd9 100644 --- a/twitch/feeds.py +++ b/twitch/feeds.py @@ -9,12 +9,16 @@ from django.utils import timezone from django.utils.html import format_html from django.utils.safestring import SafeText -from twitch.models import DropCampaign, Game, Organization, TimeBasedDrop +from twitch.models import DropCampaign +from twitch.models import Game +from twitch.models import Organization +from twitch.models import TimeBasedDrop if TYPE_CHECKING: import datetime - from django.db.models import Model, QuerySet + from django.db.models import Model + from django.db.models import QuerySet # MARK: /rss/organizations/ diff --git a/twitch/management/commands/import_drops.py b/twitch/management/commands/import_drops.py index 1d6f089..53b406a 100644 --- a/twitch/management/commands/import_drops.py +++ b/twitch/management/commands/import_drops.py @@ -6,17 +6,28 @@ import threading import traceback from functools import lru_cache from pathlib import Path -from typing import TYPE_CHECKING, Any +from typing import TYPE_CHECKING +from typing import Any import dateparser import json_repair from django.core.exceptions import MultipleObjectsReturned -from django.core.management.base import BaseCommand, CommandError, CommandParser -from django.db import DatabaseError, IntegrityError, transaction +from django.core.management.base import BaseCommand +from django.core.management.base import CommandError +from django.core.management.base import CommandParser +from django.db import DatabaseError +from django.db import IntegrityError +from django.db import transaction from django.utils import timezone from tqdm import tqdm -from twitch.models import Channel, DropBenefit, DropBenefitEdge, DropCampaign, Game, Organization, TimeBasedDrop +from twitch.models import Channel +from twitch.models import DropBenefit +from twitch.models import DropBenefitEdge +from twitch.models import DropCampaign +from twitch.models import Game +from twitch.models import Organization +from twitch.models import TimeBasedDrop if TYPE_CHECKING: from datetime import datetime diff --git a/twitch/migrations/0001_initial.py b/twitch/migrations/0001_initial.py index 29a969c..a02a5b5 100644 --- a/twitch/migrations/0001_initial.py +++ b/twitch/migrations/0001_initial.py @@ -2,7 +2,8 @@ from __future__ import annotations import django.db.models.deletion -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/twitch/urls.py b/twitch/urls.py index bdc855b..63ceb9c 100644 --- a/twitch/urls.py +++ b/twitch/urls.py @@ -5,11 +5,9 @@ from typing import TYPE_CHECKING from django.urls import path from twitch import views -from twitch.feeds import ( - DropCampaignFeed, - GameFeed, - OrganizationFeed, -) +from twitch.feeds import DropCampaignFeed +from twitch.feeds import GameFeed +from twitch.feeds import OrganizationFeed if TYPE_CHECKING: from django.urls.resolvers import URLPattern diff --git a/twitch/views.py b/twitch/views.py index 7b527ef..b6071a4 100644 --- a/twitch/views.py +++ b/twitch/views.py @@ -3,27 +3,44 @@ from __future__ import annotations import datetime import json import logging -from collections import OrderedDict, defaultdict -from typing import TYPE_CHECKING, Any +from collections import OrderedDict +from collections import defaultdict +from typing import TYPE_CHECKING +from typing import Any -from django.contrib.postgres.search import SearchQuery, SearchRank, SearchVector +from django.contrib.postgres.search import SearchQuery +from django.contrib.postgres.search import SearchRank +from django.contrib.postgres.search import SearchVector from django.core.serializers import serialize -from django.db.models import BaseManager, Count, F, Model, Prefetch, Q +from django.db.models import BaseManager +from django.db.models import Count +from django.db.models import F +from django.db.models import Model +from django.db.models import Prefetch +from django.db.models import Q from django.db.models.functions import Trim from django.db.models.query import QuerySet -from django.http import HttpRequest, HttpResponse +from django.http import HttpRequest +from django.http import HttpResponse from django.shortcuts import render from django.utils import timezone -from django.views.generic import DetailView, ListView +from django.views.generic import DetailView +from django.views.generic import ListView from pygments import highlight from pygments.formatters import HtmlFormatter from pygments.lexers.data import JsonLexer -from twitch.models import Channel, DropBenefit, DropCampaign, Game, Organization, TimeBasedDrop +from twitch.models import Channel +from twitch.models import DropBenefit +from twitch.models import DropCampaign +from twitch.models import Game +from twitch.models import Organization +from twitch.models import TimeBasedDrop if TYPE_CHECKING: from django.db.models import QuerySet - from django.http import HttpRequest, HttpResponse + from django.http import HttpRequest + from django.http import HttpResponse logger: logging.Logger = logging.getLogger(__name__)