Skip to content

fix: filter out Nones from guild.role before sorting #1457

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

Merged
merged 1 commit into from
Jun 24, 2023

Conversation

AstreaTSS
Copy link
Member

Pull Request Type

  • Feature addition
  • Bugfix
  • Documentation update
  • Code refactor
  • Tests improvement
  • CI/CD pipeline enhancement
  • Other: [Replace with a description]

Description

Yes, this is a bug fix to a bug fix. More specifically #1454.
Basically, if the cache returned None for a role, sorted would still try to sort those Nones as they haven't been filtered out yet... so you can end up in scenarios where it tries to compare a NoneType to a NoneType.

Changes

  • Use a funny list comprehension to filter out Nones in the generator passed to sorted for guild.roles.

Related Issues

Test Scenarios

Python Compatibility

  • I've ensured my code works on Python 3.10.x
  • I've ensured my code works on Python 3.11.x

Checklist

  • I've run the pre-commit code linter over all edited files
  • I've tested my changes on supported Python versions
  • I've added tests for my code, if applicable
  • I've updated / added documentation, where applicable

Copy link
Contributor

@LordOfPolls LordOfPolls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ick... but approved

@AstreaTSS
Copy link
Member Author

smh this code is totally very clean and the best example of walrus operators

@silasary
Copy link
Member

And it's much more performant than the old code

@LordOfPolls LordOfPolls merged commit b23fe82 into interactions-py:unstable Jun 24, 2023
@AstreaTSS AstreaTSS deleted the role-filter-fix branch July 2, 2023 02:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants