mirror of
https://github.com/zulip/zulip.git
synced 2025-10-22 20:42:14 +00:00
ruff: Fix PYI019 Use Self
instead of custom TypeVar.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
7cbda7d7a5
commit
88a8087243
@@ -12,7 +12,7 @@ from collections import defaultdict
|
||||
from collections.abc import Iterator
|
||||
from datetime import datetime, timezone
|
||||
from email.headerregistry import Address
|
||||
from typing import Any, TypeAlias, TypeVar
|
||||
from typing import Any, TypeAlias
|
||||
from urllib.parse import SplitResult, urlsplit
|
||||
|
||||
import orjson
|
||||
@@ -68,8 +68,6 @@ AddedChannelsT: TypeAlias = dict[str, tuple[str, int]]
|
||||
AddedMPIMsT: TypeAlias = dict[str, tuple[str, int]]
|
||||
DMMembersT: TypeAlias = dict[str, tuple[str, str]]
|
||||
SlackToZulipRecipientT: TypeAlias = dict[str, int]
|
||||
# Generic type for SlackBotEmail class
|
||||
SlackBotEmailT = TypeVar("SlackBotEmailT", bound="SlackBotEmail")
|
||||
|
||||
# We can look up unicode codepoints for Slack emoji using iamcal emoji
|
||||
# data. https://emojipedia.org/slack/, documents Slack's emoji names
|
||||
@@ -106,7 +104,7 @@ class SlackBotEmail:
|
||||
assigned_email: dict[str, str] = {}
|
||||
|
||||
@classmethod
|
||||
def get_email(cls: type[SlackBotEmailT], user_profile: ZerverFieldsT, domain_name: str) -> str:
|
||||
def get_email(cls, user_profile: ZerverFieldsT, domain_name: str) -> str:
|
||||
slack_bot_id = user_profile["bot_id"]
|
||||
if slack_bot_id in cls.assigned_email:
|
||||
return cls.assigned_email[slack_bot_id]
|
||||
|
@@ -4,13 +4,12 @@ import re
|
||||
from collections.abc import Iterator
|
||||
from contextlib import contextmanager
|
||||
from dataclasses import dataclass
|
||||
from typing import TypeVar
|
||||
|
||||
import pyvips
|
||||
from bs4 import BeautifulSoup
|
||||
from bs4.formatter import EntitySubstitution, HTMLFormatter
|
||||
from django.utils.translation import gettext as _
|
||||
from typing_extensions import override
|
||||
from typing_extensions import Self, override
|
||||
|
||||
from zerver.lib.exceptions import ErrorCode, JsonableError
|
||||
from zerver.lib.mime_types import INLINE_MIME_TYPES
|
||||
@@ -30,8 +29,6 @@ IMAGE_MAX_ANIMATED_PIXELS = IMAGE_BOMB_TOTAL_PIXELS / 3
|
||||
# Reject emoji which, after resizing, have stills larger than this
|
||||
MAX_EMOJI_GIF_FILE_SIZE_BYTES = 128 * 1024 # 128 kb
|
||||
|
||||
T = TypeVar("T", bound="BaseThumbnailFormat")
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class BaseThumbnailFormat:
|
||||
@@ -52,7 +49,7 @@ class BaseThumbnailFormat:
|
||||
return f"{self.max_width}x{self.max_height}{animated}.{self.extension}"
|
||||
|
||||
@classmethod
|
||||
def from_string(cls: type[T], format_string: str) -> T | None:
|
||||
def from_string(cls, format_string: str) -> Self | None:
|
||||
format_parts = re.match(r"(\d+)x(\d+)(-anim)?\.(\w+)$", format_string)
|
||||
if format_parts is None:
|
||||
return None
|
||||
|
Reference in New Issue
Block a user