Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
zerolab committed Dec 6, 2024
1 parent fe7838b commit 8a7119e
Show file tree
Hide file tree
Showing 20 changed files with 26 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/wagtailmedia/blocks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import TYPE_CHECKING, Type
from typing import TYPE_CHECKING

from django.forms import ModelChoiceField
from django.template.loader import render_to_string
Expand Down Expand Up @@ -52,7 +52,7 @@ def render_basic(self, value, context=None):
f"You need to implement {self.__class__.__name__}.render_basic"
)

def get_comparison_class(self) -> Type["MediaChooserBlockComparison"]:
def get_comparison_class(self) -> type["MediaChooserBlockComparison"]:
return MediaChooserBlockComparison


Expand Down
2 changes: 1 addition & 1 deletion src/wagtailmedia/wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def register_media_permissions_panel():
def describe_collection_media(collection):
media_count = get_media_model().objects.filter(collection=collection).count()
if media_count:
url = reverse("wagtailmedia:index") + ("?collection_id=%d" % collection.id)
url = reverse("wagtailmedia:index") + f"?collection_id={collection.id}"
return {
"count": media_count,
"count_text": ngettext(
Expand Down
1 change: 1 addition & 0 deletions tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from django.urls import reverse
from wagtail.models import Page
from wagtail.test.utils import WagtailTestUtils

from wagtailmedia.blocks import AbstractMediaChooserBlock


Expand Down
4 changes: 2 additions & 2 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from django.test import TestCase, override_settings
from django.urls import reverse

from wagtailmedia.models import get_media_model

from .utils import create_audio, create_video
Expand Down Expand Up @@ -66,8 +67,7 @@ def test_basic(self):

# Check detail_url
self.assertEqual(
item["meta"]["detail_url"],
"http://localhost/api/media/%d/" % item["id"],
item["meta"]["detail_url"], f"http://localhost/api/media/{item['id']}/"
)

media = Media.objects.get(pk=item["id"])
Expand Down
1 change: 1 addition & 0 deletions tests/test_blocks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.core.files.base import ContentFile
from django.test import TestCase
from django.urls import reverse

from wagtailmedia.blocks import (
AbstractMediaChooserBlock,
AudioChooserBlock,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_compare.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from django.test import TestCase
from django.utils.safestring import SafeString

from tests.testapp.models import BlogStreamPage
from wagtailmedia.blocks import (
AudioChooserBlock,
MediaChooserBlockComparison,
Expand All @@ -9,8 +11,6 @@
from wagtailmedia.models import get_media_model
from wagtailmedia.utils import format_audio_html, format_video_html

from tests.testapp.models import BlogStreamPage

from .utils import create_audio, create_video


Expand Down
4 changes: 2 additions & 2 deletions tests/test_edit_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from wagtail import VERSION as WAGTAIL_VERSION
from wagtail.admin.panels import FieldPanel, ObjectList
from wagtail.models import Page
from wagtailmedia.edit_handlers import MediaChooserPanel, MediaFieldComparison
from wagtailmedia.widgets import AdminAudioChooser, AdminMediaChooser, AdminVideoChooser

from tests.testapp.models import BlogStreamPage
from wagtailmedia.edit_handlers import MediaChooserPanel, MediaFieldComparison
from wagtailmedia.widgets import AdminAudioChooser, AdminMediaChooser, AdminVideoChooser

from .utils import create_audio, create_video

Expand Down
4 changes: 2 additions & 2 deletions tests/test_form_override.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from django import forms
from django.test import TestCase, override_settings
from wagtail.admin import widgets
from wagtailmedia import models
from wagtailmedia.forms import BaseMediaForm, get_media_base_form, get_media_form

from tests.testapp.forms import AlternateMediaForm, OverridenWidget
from wagtailmedia import models
from wagtailmedia.forms import BaseMediaForm, get_media_base_form, get_media_form


class TestFormOverride(TestCase):
Expand Down
1 change: 1 addition & 0 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.db import transaction
from django.template import Context, Template
from django.test import TestCase, override_settings

from wagtailmedia.forms import get_media_form
from wagtailmedia.models import get_media_model

Expand Down
1 change: 1 addition & 0 deletions tests/test_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.urls import reverse
from wagtail.models import Collection, GroupCollectionPermission
from wagtail.test.utils import WagtailTestUtils

from wagtailmedia import models


Expand Down
1 change: 1 addition & 0 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from unittest import mock

from django.test import TestCase, override_settings

from wagtailmedia.settings import WagtailMediaSettings, wagtailmedia_settings


Expand Down
1 change: 1 addition & 0 deletions tests/test_tags.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from unittest.mock import patch

from django.test import TestCase

from wagtailmedia.templatetags.media_tags import wagtail_version_gte


Expand Down
1 change: 1 addition & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.core.files.base import ContentFile
from django.test import TestCase

from wagtailmedia.models import get_media_model
from wagtailmedia.utils import format_audio_html, format_video_html

Expand Down
2 changes: 1 addition & 1 deletion tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from django.urls import NoReverseMatch, reverse
from wagtail.models import Collection, GroupCollectionPermission
from wagtail.test.utils import WagtailTestUtils
from wagtailmedia import models

from tests.testapp.models import EventPage, EventPageRelatedMedia
from wagtailmedia import models


class TestMediaIndexView(TestCase, WagtailTestUtils):
Expand Down
1 change: 1 addition & 0 deletions tests/test_widgets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.test import TestCase
from django.urls import reverse

from wagtailmedia import widgets
from wagtailmedia.widgets import AdminAudioChooser, AdminMediaChooser, AdminVideoChooser

Expand Down
1 change: 1 addition & 0 deletions tests/testapp/forms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.forms.widgets import Widget

from wagtailmedia.forms import BaseMediaForm


Expand Down
3 changes: 2 additions & 1 deletion tests/testapp/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
import wagtail.blocks
import wagtail.fields
import wagtail.search.index
import wagtailmedia.blocks

from django.conf import settings
from django.db import migrations, models

import wagtailmedia.blocks


try:
import wagtail.models.media as collections
Expand Down
1 change: 1 addition & 0 deletions tests/testapp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from wagtail.admin.panels import FieldPanel, InlinePanel
from wagtail.fields import RichTextField, StreamField
from wagtail.models import Orderable, Page

from wagtailmedia.blocks import (
AbstractMediaChooserBlock,
AudioChooserBlock,
Expand Down
1 change: 1 addition & 0 deletions tests/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from wagtail.admin import urls as wagtailadmin_urls
from wagtail.api.v2.router import WagtailAPIRouter
from wagtail.documents import urls as wagtaildocs_urls

from wagtailmedia.api.views import MediaAPIViewSet


Expand Down
1 change: 1 addition & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Optional

from django.core.files.base import ContentFile

from wagtailmedia.models import MediaType, get_media_model


Expand Down

0 comments on commit 8a7119e

Please sign in to comment.