Update Ruff and fix its errors
This commit is contained in:
parent
c54ceeb7a8
commit
1424978854
39 changed files with 183 additions and 175 deletions
|
|
@ -496,7 +496,7 @@ class KickCategoryCampaignFeed(TTVDropsBaseFeed):
|
|||
self._limit = None
|
||||
return super().__call__(request, *args, **kwargs)
|
||||
|
||||
def get_object(self, request: HttpRequest, kick_id: int) -> KickCategory: # noqa: ARG002
|
||||
def get_object(self, request: HttpRequest, kick_id: int) -> KickCategory: # ruff:ignore[unused-method-argument]
|
||||
"""Return game object for this feed URL."""
|
||||
return KickCategory.objects.get(kick_id=kick_id)
|
||||
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ class Command(BaseCommand):
|
|||
|
||||
try:
|
||||
payload: dict = response.json()
|
||||
except Exception as exc: # noqa: BLE001
|
||||
except Exception as exc: # ruff:ignore[blind-except]
|
||||
self.stderr.write(self.style.ERROR(f"Failed to parse JSON response: {exc}"))
|
||||
return
|
||||
|
||||
|
|
@ -166,7 +166,7 @@ class Command(BaseCommand):
|
|||
self.style.SUCCESS(f"Imported {imported}/{len(campaigns)} campaign(s)."),
|
||||
)
|
||||
|
||||
def _import_campaign(self, data: KickDropCampaignSchema) -> None: # noqa: PLR0914, PLR0915
|
||||
def _import_campaign(self, data: KickDropCampaignSchema) -> None: # ruff:ignore[too-many-locals, too-many-statements]
|
||||
"""Import a single campaign and all its related objects."""
|
||||
# Organization
|
||||
org_data: KickOrganizationSchema = data.organization
|
||||
|
|
|
|||
|
|
@ -93,12 +93,12 @@ class KickCategory(auto_prefetch.Model):
|
|||
|
||||
@property
|
||||
def get_absolute_url(self) -> str:
|
||||
"""Return the URL to the game detail page."""
|
||||
"""The URL to the game detail page."""
|
||||
return reverse("kick:game_detail", args=[self.kick_id])
|
||||
|
||||
@property
|
||||
def kick_url(self) -> str:
|
||||
"""Return the URL to the game page on Kick."""
|
||||
"""The URL to the game page on Kick."""
|
||||
return f"https://kick.com/category/{self.slug}" if self.slug else ""
|
||||
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ class KickUser(auto_prefetch.Model):
|
|||
|
||||
@property
|
||||
def kick_profile_url(self) -> str:
|
||||
"""Return the Kick profile URL for this user."""
|
||||
"""The Kick profile URL for this user."""
|
||||
return f"https://kick.com/{self.username}" if self.username else ""
|
||||
|
||||
|
||||
|
|
@ -183,7 +183,7 @@ class KickChannel(auto_prefetch.Model):
|
|||
|
||||
@property
|
||||
def channel_url(self) -> str:
|
||||
"""Return the Kick channel URL."""
|
||||
"""The Kick channel URL."""
|
||||
return f"https://kick.com/{self.slug}" if self.slug else ""
|
||||
|
||||
|
||||
|
|
@ -290,7 +290,7 @@ class KickDropCampaign(auto_prefetch.Model):
|
|||
|
||||
@property
|
||||
def image_url(self) -> str:
|
||||
"""Return the image URL for the campaign."""
|
||||
"""The image URL for the campaign."""
|
||||
# Image from first drop
|
||||
rewards_prefetched: list[KickReward] | None = getattr(
|
||||
self,
|
||||
|
|
@ -356,7 +356,7 @@ class KickDropCampaign(auto_prefetch.Model):
|
|||
|
||||
@property
|
||||
def merged_rewards(self) -> list[KickReward]:
|
||||
"""Return rewards de-duplicated by normalized name.
|
||||
"""Rewards de-duplicated by normalized name.
|
||||
|
||||
If both a base reward and a "(Con)" variant exist, prefer the base reward name.
|
||||
"""
|
||||
|
|
@ -455,7 +455,7 @@ class KickReward(auto_prefetch.Model):
|
|||
|
||||
@property
|
||||
def full_image_url(self) -> str:
|
||||
"""Return the absolute image URL for this reward.
|
||||
"""The absolute image URL for this reward.
|
||||
|
||||
If the image_url is a relative path, prepend the Kick image base URL.
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from datetime import datetime # noqa: TC003
|
||||
from datetime import datetime # ruff:ignore[typing-only-standard-library-import]
|
||||
|
||||
from pydantic import BaseModel
|
||||
from pydantic import Field
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ logger = logging.getLogger("ttvdrops.tasks")
|
|||
|
||||
|
||||
@shared_task(bind=True, queue="api-fetches", max_retries=3, default_retry_delay=120)
|
||||
def import_kick_drops(self) -> None: # noqa: ANN001
|
||||
def import_kick_drops(self) -> None: # ruff:ignore[missing-type-function-argument]
|
||||
"""Fetch and upsert Kick drop campaigns from the public API."""
|
||||
try:
|
||||
call_command("import_kick_drops")
|
||||
|
|
|
|||
|
|
@ -463,7 +463,7 @@ class KickDropCampaignMergedRewardsTest(TestCase):
|
|||
class ImportKickDropsCommandTest(TestCase):
|
||||
"""Tests for the import_kick_drops management command."""
|
||||
|
||||
def _run_command(self, json_payload: dict, **options: Any) -> tuple[str, str]: # noqa: ANN401
|
||||
def _run_command(self, json_payload: dict, **options: Any) -> tuple[str, str]: # ruff:ignore[any-type]
|
||||
|
||||
mock_response = MagicMock()
|
||||
mock_response.json.return_value = json_payload
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue