Skip to content

RET selection is behaving incorrectly #3989

@charliermarsh

Description

@charliermarsh

Given:

from typing import Optional


def system_content(self) -> Optional[str]:
    if self.type is MessageType.role_subscription_purchase:
        if not (data := self.role_subscription_data):
            return

        guild_name = f"**{self.guild.name}**" if self.guild else None
        if data.total_months_subscribed > 0:
            action = "renewed" if data.is_renewal else "joined"
            return (
                f"{self.author.name} {action} **{data.tier_name}** and has been a subscriber "
                f"of {guild_name} for {data.total_months_subscribed} "
                f"{'month' if data.total_months_subscribed == 1 else 'months'}!"
            )
        elif data.is_renewal:
            return f"{self.author.name} renewed **{data.tier_name}** in their {guild_name} membership!"
        else:
            return f"{self.author.name} joined **{data.tier_name}** as a subscriber of {guild_name}!"

    return None

Running ruff . --select RET505 --select RET502 raises RET505, but not RET502.

Reported on Discord.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions