Skip to content

Conversation

Paillat-dev
Copy link
Member

@Paillat-dev Paillat-dev commented Mar 4, 2025

Summary

Changes made:

  • Added typing for SlashCommand.parent
  • Added BridgeCommand.__bridge__ which is True
  • Replaced weird checks to assess something is a BridgeCommand by checking it has an add_to attribute (BridgeCommand is the only class in py-cord that has such method) with a TypeGuard that checks it has a __bridge__ attribute (which also makes this typed and that's cool)
  • Fixed typing of CogMeta.__cog_commands__
  • Rename name_filter to _name_filter and define it outside of __new__ to avoid redefining it every time and also avoid assigning a lambda to a variable.
  • Extract name validation logic (disallow the bot_ or cog_ prefixes) to a helper function _validate_name_prefix.
  • Extract class attributes iteration and processing to helper function _process_attributes. Simplify it by changing overengineered checks and simplifying dead code. Rename elem, value to attr_name, attr_value
  • Extract command update logic to _update_command, idem as above.
  • Import Generator & Mapping from collections.abc instead of typing (deprecated since python 3.9).

Tested and fixed all the issues I found, but it would be nice if someone else could also test this to make sure I didn't miss anything.

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.

@Paillat-dev Paillat-dev changed the title refactor: Refactor weird checks in CogMeta and fix some typing refactor: Refactor weird checks in CogMeta and fix some typing and other qol things Mar 4, 2025
@Paillat-dev Paillat-dev changed the title refactor: Refactor weird checks in CogMeta and fix some typing and other qol things refactor: ♻️ Refactor weird checks in CogMeta and fix some typing and other qol things Mar 4, 2025
@Paillat-dev Paillat-dev marked this pull request as ready for review March 9, 2025 18:11
@Paillat-dev Paillat-dev requested review from a team as code owners March 9, 2025 18:11
@pullapprove4 pullapprove4 bot requested a review from Lulalaby March 9, 2025 18:11
@Lulalaby Lulalaby requested a review from a team as a code owner August 30, 2025 20:33
@Lulalaby Lulalaby force-pushed the master branch 2 times, most recently from b55c125 to 82659b2 Compare August 30, 2025 21:10
@Lulalaby Lulalaby removed the on hold label Aug 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants