ronantakizawa/codereview-bench huggingface dataset:
Repository: Rapptz/discord.py
File: discord/guild.py (Python)

Code before:
        if not self.invites_paused_until:
            return False

        return self.invites_paused_until > utils.utcnow()

    def dms_paused(self) -> bool:
        """:class:`bool`: Whether DMs are paused in the guild.

        .. versionadded:: 2.4
        """
        if not self.dms_paused_until:
            return False

        return self.dms_paused_until > utils.utcnow()

    def dm_spam_detected(self) -> bool:
        """:class:`bool`: Whether DM spam was detected in the guild.

        .. versionadded:: 2.4
        """
        if not self.dm_spam_detected_at:
            return False

        return self.dm_spam_detected_at > utils.utcnow()

    def raid_detected(self) -> bool:
        """:class:`bool`: Whether a raid was detected in the guild.

        .. versionadded:: 2.4
        """
        if not self.raid_detected_at:
            return False

        return self.raid_detected_at > utils.utcnow()


Review comment (suggestion):
```suggestion
    def is_raid_detected(self) -> bool:
```

Code after:

        return utils.parse_time(self._incidents_data.get('dm_spam_detected_at'))

    @property
    def raid_detected_at(self) -> Optional[datetime.datetime]:
        """Optional[:class:`datetime.datetime`]: Returns the time when a raid was detected in the guild.

        .. versionadded:: 2.5
        """
        if not self._incidents_data:
            return None

        return utils.parse_time(self._incidents_data.get('raid_detected_at'))

    def invites_paused(self) -> bool:
        """:class:`bool`: Whether invites are paused in the guild.

        .. versionadded:: 2.4
        """
        if not self.invites_paused_until:
            return False

        return self.invites_paused_until > utils.utcnow()

    def dms_paused(self) -> bool:
        """:class:`bool`: Whether DMs are paused in the guild.

        .. versionadded:: 2.4
        """
        if not self.dms_paused_until:
            return 'INVITES_DISABLED' in self.features

        return self.dms_paused_until > utils.utcnow()

    def is_dm_spam_detected(self) -> bool:
        """:class:`bool`: Whether DM spam was detected in the guild.

        .. versionadded:: 2.5
        """
        if not self.dm_spam_detected_at:
            return False

        return self.dm_spam_detected_at > utils.utcnow()

    def is_raid_detected(self) -> bool:
        """:class:`bool`: Whether a raid was detected in the guild.

        .. versionadded:: 2.5
        """
        if not self.raid_detected_at:
            return False
Repository: Rapptz/discord.py
File: discord/types/appinfo.py (Python)

Code before:
    bot_public: bool
    bot_require_code_grant: bool
    team: NotRequired[Team]
    guild_id: NotRequired[Snowflake]
    primary_sku_id: NotRequired[Snowflake]
    slug: NotRequired[str]
    hook: NotRequired[bool]
    max_participants: NotRequired[int]
    tags: NotRequired[List[str]]
    install_params: NotRequired[InstallParams]
    custom_install_url: NotRequired[str]


class PartialAppInfo(BaseAppInfo, total=False):
    hook: bool
    max_participants: int
    approximate_guild_count: int


class GatewayAppInfo(TypedDict):
    id: Snowflake
    flags: int


class ListAppEmojis(TypedDict):
    items: list[Emoji]


Review comment (suggestion):
Drops support for Python 3.8
```suggestion
    items: List[Emoji]
```

Code after:
    owner: User
    bot_public: bool
    bot_require_code_grant: bool
    team: NotRequired[Team]
    guild_id: NotRequired[Snowflake]
    primary_sku_id: NotRequired[Snowflake]
    slug: NotRequired[str]
    hook: NotRequired[bool]
    max_participants: NotRequired[int]
    tags: NotRequired[List[str]]
    install_params: NotRequired[InstallParams]
    custom_install_url: NotRequired[str]


class PartialAppInfo(BaseAppInfo, total=False):
    hook: bool
    max_participants: int
    approximate_guild_count: int


class GatewayAppInfo(TypedDict):
    id: Snowflake
    flags: int


class ListAppEmojis(TypedDict):
    items: List[Emoji]
Repository: Rapptz/discord.py
File: discord/client.py (Python)

Code before:
            The emoji name. Must be at least 2 characters.
        image: :class:`bytes`
            The :term:`py:bytes-like object` representing the image data to use.
            Only JPG, PNG and GIF images are supported.

        Raises
        ------
        MissingApplicationID
            The application ID could not be found.
        HTTPException
            Creating the emoji failed.

        Returns
        -------
        :class:`.Emoji`
            The emoji that was created.
        """
        if self.application_id is None:
            raise MissingApplicationID

        img = utils._bytes_to_base64_data(image)
        data = await self.http.create_application_emoji(self.application_id, name, img)
        guild = self._connection._get_or_create_unavailable_guild(0)
        return Emoji(guild=guild, state=self._connection, data=data)

    async def fetch_emoji(self, emoji_id: int, /) -> Emoji:
        """|coro|

        Retrieves an emoji for the current application.

        .. versionadded:: 2.5

        Parameters
        ----------
        emoji_id: :class:`int`
            The emoji ID to retrieve.

        Raises
        ------
        MissingApplicationID
            The application ID could not be found.
        HTTPException
            Retrieving the emoji failed.

        Returns
        -------
        :class:`.Emoji`
            The emoji requested.
        """
        if self.application_id is None:
            raise MissingApplicationID

Review comment (suggestion):
```suggestion
    async def fetch_application_emoji(self, emoji_id: int, /) -> Emoji:
```

Code after:
        if not isinstance(view, View):
            raise TypeError(f'expected an instance of View not {view.__class__.__name__}')

        if not view.is_persistent():
            raise ValueError('View is not persistent. Items need to have a custom_id set and View must have no timeout')

        if view.is_finished():
            raise ValueError('View is already finished.')

        self._connection.store_view(view, message_id)

    @property
    def persistent_views(self) -> Sequence[View]:
        """Sequence[:class:`.View`]: A sequence of persistent views added to the client.

        .. versionadded:: 2.0
        """
        return self._connection.persistent_views

    async def create_application_emoji(
        self,
        *,
        name: str,
        image: bytes,
    ) -> Emoji:
        """|coro|

        Create an emoji for the current application.

        .. versionadded:: 2.5

        Parameters
        ----------
        name: :class:`str`
            The emoji name. Must be at least 2 characters.
        image: :class:`bytes`
            The :term:`py:bytes-like object` representing the image data to use.
            Only JPG, PNG and GIF images are supported.

        Raises
        ------
        MissingApplicationID
            The application ID could not be found.
        HTTPException
            Creating the emoji failed.

        Returns
        -------
        :class:`.Emoji`
            The emoji that was created.
        """
Repository: Rapptz/discord.py
File: discord/client.py (Python)

Code before:

        Parameters
        ----------
        emoji_id: :class:`int`
            The emoji ID to retrieve.

        Raises
        ------
        MissingApplicationID
            The application ID could not be found.
        HTTPException
            Retrieving the emoji failed.

        Returns
        -------
        :class:`.Emoji`
            The emoji requested.
        """
        if self.application_id is None:
            raise MissingApplicationID

        data = await self.http.get_application_emoji(self.application_id, emoji_id)
        guild = self._connection._get_or_create_unavailable_guild(0)
        return Emoji(guild=guild, state=self._connection, data=data)

    async def fetch_emojis(self) -> List[Emoji]:
        """|coro|

        Retrieves all emojis for the current application.

        .. versionadded:: 2.5

        Raises
        -------
        MissingApplicationID
            The application ID could not be found.
        HTTPException
            Retrieving the emojis failed.

        Returns
        -------
        List[:class:`.Emoji`]
            The list of emojis for the current application.
        """
        if self.application_id is None:
            raise MissingApplicationID

        data = await self.http.get_application_emojis(self.application_id)
        guild = self._connection._get_or_create_unavailable_guild(0)
        return [Emoji(guild=guild, state=self._connection, data=emoji) for emoji in data['items']]


Review comment (suggestion):
```suggestion
    async def fetch_application_emojis(self) -> List[Emoji]:
```

Code after:
        Parameters
        ----------
        name: :class:`str`
            The emoji name. Must be at least 2 characters.
        image: :class:`bytes`
            The :term:`py:bytes-like object` representing the image data to use.
            Only JPG, PNG and GIF images are supported.

        Raises
        ------
        MissingApplicationID
            The application ID could not be found.
        HTTPException
            Creating the emoji failed.

        Returns
        -------
        :class:`.Emoji`
            The emoji that was created.
        """
        if self.application_id is None:
            raise MissingApplicationID

        img = utils._bytes_to_base64_data(image)
        data = await self.http.create_application_emoji(self.application_id, name, img)
        return Emoji(guild=Object(0), state=self._connection, data=data)

    async def fetch_application_emoji(self, emoji_id: int, /) -> Emoji:
        """|coro|

        Retrieves an emoji for the current application.

        .. versionadded:: 2.5

        Parameters
        ----------
        emoji_id: :class:`int`
            The emoji ID to retrieve.

        Raises
        ------
        MissingApplicationID
            The application ID could not be found.
        HTTPException
            Retrieving the emoji failed.

        Returns
        -------
        :class:`.Emoji`
            The emoji requested.
        """
Repository: Rapptz/discord.py
File: discord/enums.py (Python)

Code before:
                return value


class ChannelType(Enum):
    text = 0
    private = 1
    voice = 2
    group = 3
    category = 4
    news = 5
    news_thread = 10
    public_thread = 11
    private_thread = 12
    stage_voice = 13
    forum = 15
    media = 16

    def __str__(self) -> str:
        return self.name


class MessageReferenceType(Enum):
    reply = 0
    forward = 1

    default = 0


class MessageType(Enum):
    default = 0
    recipient_add = 1
    recipient_remove = 2
    call = 3
    channel_name_change = 4
    channel_icon_change = 5
    pins_add = 6
    new_member = 7
    premium_guild_subscription = 8
    premium_guild_tier_1 = 9
    premium_guild_tier_2 = 10
    premium_guild_tier_3 = 11
    channel_follow_add = 12
    guild_stream = 13
    guild_discovery_disqualified = 14
    guild_discovery_requalified = 15
    guild_discovery_grace_period_initial_warning = 16
    guild_discovery_grace_period_final_warning = 17
    thread_created = 18
    reply = 19
    chat_input_command = 20
    thread_starter_message = 21

Review comment (suggestion):
```suggestion
class MessageReferenceType(Enum):
    default = 0
    reply = 0
    forward = 1
```

Code after:
                return cls._enum_value_map_[value]
            except (KeyError, TypeError):
                return value


class ChannelType(Enum):
    text = 0
    private = 1
    voice = 2
    group = 3
    category = 4
    news = 5
    news_thread = 10
    public_thread = 11
    private_thread = 12
    stage_voice = 13
    forum = 15
    media = 16

    def __str__(self) -> str:
        return self.name


class MessageReferenceType(Enum):
    default = 0
    reply = 0
    forward = 1


class MessageType(Enum):
    default = 0
    recipient_add = 1
    recipient_remove = 2
    call = 3
    channel_name_change = 4
    channel_icon_change = 5
    pins_add = 6
    new_member = 7
    premium_guild_subscription = 8
    premium_guild_tier_1 = 9
    premium_guild_tier_2 = 10
    premium_guild_tier_3 = 11
    channel_follow_add = 12
    guild_stream = 13
    guild_discovery_disqualified = 14
    guild_discovery_requalified = 15
    guild_discovery_grace_period_initial_warning = 16
    guild_discovery_grace_period_final_warning = 17
    thread_created = 18
    reply = 19
    chat_input_command = 20
Repository: Rapptz/discord.py
File: discord/guild.py (Python)

Code before:

    VocalGuildChannel = Union[VoiceChannel, StageChannel]
    GuildChannel = Union[VocalGuildChannel, ForumChannel, TextChannel, CategoryChannel]
    ByCategoryItem = Tuple[Optional[CategoryChannel], List[GuildChannel]]


class BanEntry(NamedTuple):
    reason: Optional[str]
    user: User


class BulkBanResult(NamedTuple):
    banned: List[Object]
    failed: List[Object]


class _GuildLimit(NamedTuple):
    emoji: int
    stickers: int
    bitrate: float
    filesize: int


class GuildPreview(Hashable):
    """Represents a preview of a Discord guild.

    .. container:: operations

        .. describe:: x == y

            Checks if two guild previews are equal.

        .. describe:: x != y

            Checks if two guild previews are not equal.

        .. describe:: hash(x)

            Returns the guild's hash.

        .. describe:: str(x)

            Returns the guild's name.

    Attributes
    ----------
    name: :class:`str`
        The guild preview's name.
    id: :class:`int`
        The guild preview's ID.
    features: List[:class:`str`]

Review comment (suggestion):
```suggestion
    """Represents a preview of a Discord guild.

        .. versionadded:: 2.5
```

Code after:

    VocalGuildChannel = Union[VoiceChannel, StageChannel]
    GuildChannel = Union[VocalGuildChannel, ForumChannel, TextChannel, CategoryChannel]
    ByCategoryItem = Tuple[Optional[CategoryChannel], List[GuildChannel]]


class BanEntry(NamedTuple):
    reason: Optional[str]
    user: User


class BulkBanResult(NamedTuple):
    banned: List[Object]
    failed: List[Object]


class _GuildLimit(NamedTuple):
    emoji: int
    stickers: int
    bitrate: float
    filesize: int


class GuildPreview(Hashable):
    """Represents a preview of a Discord guild.

        .. versionadded:: 2.5

    .. container:: operations

        .. describe:: x == y

            Checks if two guild previews are equal.

        .. describe:: x != y

            Checks if two guild previews are not equal.

        .. describe:: hash(x)

            Returns the guild's hash.

        .. describe:: str(x)

            Returns the guild's name.

    Attributes
    ----------
    name: :class:`str`
        The guild preview's name.
    id: :class:`int`
Repository: Rapptz/discord.py
File: discord/primary_guild.py (Python)

Code before:
        _state: ConnectionState
    
    def __init__(self, *, state, data: PrimaryGuildPayload) -> None:
        self._state = state
        self._update(data)

    def _update(self, data: PrimaryGuildPayload):
        self.guild_id = data["identity_guild_id"]
        self.identity_enabled = data['identity_enabled']
        self.tag = data['tag']
        self._badge = data['badge']
    
    @property
    def badge(self) -> Asset:
        """:class:`Asset`: Returns the primary guild's asset"""
        return Asset._from_primary_guild(self._state, self.guild_id, self._badge)
    
    @property
    def created_at(self) -> datetime:
        """:class:`datetime.datetime`: Returns the primary guild's creation time in UTC.
        """
        return snowflake_time(self.guild_id)
    
    def __repr__(self) -> str:
        return (
            f"<guild_id={self.guild_id} identity_enabled={self.identity_enabled} tag={self.tag}"
            f" badge={self.badge}>"
        )


Review comment (suggestion):
```suggestion
            f'<PrimaryGuild guild_id={self.guild_id} identity_enabled={self.identity_enabled} tag={self.tag}'
```

Code after:
    identity_enabled: Optional[:class:`bool`]
        Whether the user has their primary guild publicly displayed. If ``None``, the user has a public guild but has not reaffirmed the guild identity after a change

        .. warning::

            Users can have their primary guild publicly displayed while still having an :attr:`id` of ``None``. Be careful when checking this attribute!
    """

    __slots__ = ('id', 'identity_enabled', 'tag', '_badge', '_state')

    def __init__(self, *, state: ConnectionState, data: PrimaryGuildPayload) -> None:
        self._state = state
        self._update(data)

    def _update(self, data: PrimaryGuildPayload):
        self.id = _get_as_snowflake(data, 'identity_guild_id')
        self.identity_enabled = data['identity_enabled']
        self.tag = data.get('tag', None)
        self._badge = data.get('badge')

    @property
    def badge(self) -> Optional[Asset]:
        """Optional[:class:`Asset`]: Returns the primary guild's asset"""
        if self._badge is not None and self.id is not None:
            return Asset._from_primary_guild(self._state, self.id, self._badge)
        return None

    @property
    def created_at(self) -> Optional[datetime]:
        """Optional[:class:`datetime.datetime`]: Returns the primary guild's creation time in UTC."""
        if self.id is not None:
            return snowflake_time(self.id)
        return None

    @classmethod
    def _default(cls, state: ConnectionState) -> Self:
        payload: PrimaryGuildPayload = {"identity_enabled": False}  # type: ignore
        return cls(state=state, data=payload)

    def __repr__(self) -> str:
        return f'<PrimaryGuild id={self.id} identity_enabled={self.identity_enabled} tag={self.tag!r}>'
Repository: Rapptz/discord.py
File: discord/primary_guild.py (Python)

Code before:
    
    def __init__(self, *, state, data: PrimaryGuildPayload) -> None:
        self._state = state
        self._update(data)

    def _update(self, data: PrimaryGuildPayload):
        self.guild_id = data["identity_guild_id"]
        self.identity_enabled = data['identity_enabled']
        self.tag = data['tag']
        self._badge = data['badge']
    
    @property
    def badge(self) -> Asset:
        """:class:`Asset`: Returns the primary guild's asset"""
        return Asset._from_primary_guild(self._state, self.guild_id, self._badge)
    
    @property
    def created_at(self) -> datetime:
        """:class:`datetime.datetime`: Returns the primary guild's creation time in UTC.
        """
        return snowflake_time(self.guild_id)
    
    def __repr__(self) -> str:
        return (
            f"<guild_id={self.guild_id} identity_enabled={self.identity_enabled} tag={self.tag}"
            f" badge={self.badge}>"
        )


Review comment (suggestion):
single quotes
```suggestion
            f' badge={self.badge}>'
```

Code after:
        Whether the user has their primary guild publicly displayed. If ``None``, the user has a public guild but has not reaffirmed the guild identity after a change

        .. warning::

            Users can have their primary guild publicly displayed while still having an :attr:`id` of ``None``. Be careful when checking this attribute!
    """

    __slots__ = ('id', 'identity_enabled', 'tag', '_badge', '_state')

    def __init__(self, *, state: ConnectionState, data: PrimaryGuildPayload) -> None:
        self._state = state
        self._update(data)

    def _update(self, data: PrimaryGuildPayload):
        self.id = _get_as_snowflake(data, 'identity_guild_id')
        self.identity_enabled = data['identity_enabled']
        self.tag = data.get('tag', None)
        self._badge = data.get('badge')

    @property
    def badge(self) -> Optional[Asset]:
        """Optional[:class:`Asset`]: Returns the primary guild's asset"""
        if self._badge is not None and self.id is not None:
            return Asset._from_primary_guild(self._state, self.id, self._badge)
        return None

    @property
    def created_at(self) -> Optional[datetime]:
        """Optional[:class:`datetime.datetime`]: Returns the primary guild's creation time in UTC."""
        if self.id is not None:
            return snowflake_time(self.id)
        return None

    @classmethod
    def _default(cls, state: ConnectionState) -> Self:
        payload: PrimaryGuildPayload = {"identity_enabled": False}  # type: ignore
        return cls(state=state, data=payload)

    def __repr__(self) -> str:
        return f'<PrimaryGuild id={self.id} identity_enabled={self.identity_enabled} tag={self.tag!r}>'
Repository: Rapptz/discord.py
File: discord/primary_guild.py (Python)

Code before:
        identity_enabled: Optional[bool]
        tag: Optional[str]
        _badge: Optional[str]
        _state: ConnectionState

    def __init__(self, *, state, data: PrimaryGuildPayload) -> None:
        self._state = state
        self._update(data)

    def _update(self, data: PrimaryGuildPayload):
        self.id = _get_as_snowflake(data, 'identity_guild_id')
        self.identity_enabled = data['identity_enabled']
        self.tag = data.get('tag', None)
        self._badge = data.get('badge')

    @property
    def badge(self) -> Optional[Asset]:
        """Optional[:class:`Asset`]: Returns the primary guild's asset"""
        if self._badge and self.id:
            return Asset._from_primary_guild(self._state, self.id, self._badge)
        return None

    @property
    def created_at(self) -> Optional[datetime]:
        """Optional[:class:`datetime.datetime`]: Returns the primary guild's creation time in UTC."""
        if self.id:
            return snowflake_time(self.id)
        return None

    @classmethod
    def _default(cls, state: ConnectionState) -> Self:
        payload: PrimaryGuildPayload = {"identity_guild_id": None, "identity_enabled": False, "tag": None, "badge": None}
        return cls(state=state, data=payload)

    def __repr__(self) -> str:
        return f'<PrimaryGuild id={self.id} identity_enabled={self.identity_enabled} tag={self.tag!r}>'


Review comment (suggestion):
```suggestion
        if self.id is not None:
```

Code after:
    def __init__(self, *, state: ConnectionState, data: PrimaryGuildPayload) -> None:
        self._state = state
        self._update(data)

    def _update(self, data: PrimaryGuildPayload):
        self.id = _get_as_snowflake(data, 'identity_guild_id')
        self.identity_enabled = data['identity_enabled']
        self.tag = data.get('tag', None)
        self._badge = data.get('badge')

    @property
    def badge(self) -> Optional[Asset]:
        """Optional[:class:`Asset`]: Returns the primary guild's asset"""
        if self._badge is not None and self.id is not None:
            return Asset._from_primary_guild(self._state, self.id, self._badge)
        return None

    @property
    def created_at(self) -> Optional[datetime]:
        """Optional[:class:`datetime.datetime`]: Returns the primary guild's creation time in UTC."""
        if self.id is not None:
            return snowflake_time(self.id)
        return None

    @classmethod
    def _default(cls, state: ConnectionState) -> Self:
        payload: PrimaryGuildPayload = {"identity_enabled": False}  # type: ignore
        return cls(state=state, data=payload)

    def __repr__(self) -> str:
        return f'<PrimaryGuild id={self.id} identity_enabled={self.identity_enabled} tag={self.tag!r}>'