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

fix: AttributeError when comparing commands #2299

Merged
merged 11 commits into from
Jan 24, 2024

Conversation

Dorukyum
Copy link
Member

@Dorukyum Dorukyum commented Dec 25, 2023

Summary

Fixes AttributeErrors that occur when comparing application commands with non-command objects.

Information

  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed).
  • This PR is not a code change (e.g. documentation, README, typehinting,
    examples, ...).

Checklist

  • I have searched the open pull requests for duplicates.
  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why.
  • I have updated the changelog to include these changes.

@Dorukyum Dorukyum added bug Something isn't working priority: high High Priority status: awaiting review Awaiting review from a maintainer labels Dec 25, 2023
@Dorukyum Dorukyum self-assigned this Dec 25, 2023
@Dorukyum Dorukyum requested a review from a team as a code owner December 25, 2023 09:07
@Lulalaby
Copy link
Member

mhh i would be careful with such a check.
a simple dict eq check won't do i fear and might cause ratelimit hits.

@Lulalaby Lulalaby self-requested a review December 25, 2023 11:32
@Dorukyum
Copy link
Member Author

@Lulalaby I don't quite understand why this won't do, what's the issue and what do you suggest?

@Lulalaby
Copy link
Member

discord tends to mess up the received orders of properties and send back complete different ones.
I'm not sure how pythons methods work but for c# it caused many problems.
I feel like this wouldn't make it precise.. instead more unprecise
I might be wrong

@Dorukyum
Copy link
Member Author

I might've overlooked stuff like that, will look into our sync algorithm again to see if this could cause any issues.

@plun1331
Copy link
Member

discord tends to mess up the received orders of properties and send back complete different ones. I'm not sure how pythons methods work but for c# it caused many problems. I feel like this wouldn't make it precise.. instead more unprecise I might be wrong

if you're referring to the order in which the data is sent back, i believe dictionaries are unordered by default

@Dorukyum
Copy link
Member Author

Yes, that's right, but I figured I'd still check everything in case some info is missing somewhere or whatever ({"a": 1} is not equal to {"a": 1, "b": 2}). Will update today.

@Dorukyum
Copy link
Member Author

I think the only thing this will break is Bot.add_application_command as it loops through pending application commands to update their IDs. I suggest we update that method before merging this PR to fix the AttributeErrors, but eventually refactor the way commands are stored.

@Lulalaby
Copy link
Member

good that i reminded you to check

@Dorukyum Dorukyum changed the title fix: make ApplicationCommand.__eq__ precise fix: AttributeError when comparing commands Jan 1, 2024
@Dorukyum
Copy link
Member Author

Dorukyum commented Jan 1, 2024

Now that I think about it, it actually comes down to what we want this method to check: either the commands having the same frontend (the same name in the same guilds) or the commands being completely identical. I reworked this pull request to only fix the potential AttributeErrors, while keeping the original functionality of the method.

@Dorukyum Dorukyum enabled auto-merge (squash) January 24, 2024 08:50
Lulalaby
Lulalaby previously approved these changes Jan 24, 2024
@Dorukyum Dorukyum merged commit 33d6543 into Pycord-Development:master Jan 24, 2024
29 checks passed
@Dorukyum Dorukyum deleted the better-eq branch January 25, 2024 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority: high High Priority status: awaiting review Awaiting review from a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants