Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RET selection is behaving incorrectly #3989

Closed
charliermarsh opened this issue Apr 16, 2023 · 2 comments · Fixed by #4002
Closed

RET selection is behaving incorrectly #3989

charliermarsh opened this issue Apr 16, 2023 · 2 comments · Fixed by #4002
Labels
bug Something isn't working

Comments

@charliermarsh
Copy link
Member

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.

@charliermarsh charliermarsh added the bug Something isn't working label Apr 16, 2023
@charliermarsh
Copy link
Member Author

This is consistent with flake8-return, but I think we should tweak the behavior. It's a little confusing.

@charliermarsh
Copy link
Member Author

Effectively, if we detect a RET505 error, we abort, and skip some of the later checks (like RET502).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant