refactor: ♻️ Refactor weird checks in CogMeta and fix some typing and other qol things#2730
Merged
Lulalaby merged 16 commits intoPycord-Development:masterfrom Oct 21, 2025
Merged
Conversation
34e8104 to
e127333
Compare
CogMeta and fix some typingCogMeta and fix some typing and other qol things
CogMeta and fix some typing and other qol thingsCogMeta and fix some typing and other qol things
f597e62 to
2787966
Compare
…typing` Deprecated since python 3.9, py-cord supports 3.9+
Signed-off-by: Paillat <me@paillat.dev>
b55c125 to
82659b2
Compare
Lulalaby
approved these changes
Oct 21, 2025
Paillat-dev
added a commit
to Pycord-Development/pycord-next
that referenced
this pull request
Oct 26, 2025
…nd other qol things (Pycord-Development#2730) * 🏷️ Type stuff * ♻️ Refactor weird checks and don't redefine filter every time * ♻️ Extract name validation logic to helper method `_validate_name_prefix` * ♻️ Rename `elem, value` to `attr_name, attr_value` * ♻️ Extract attributes processing to `_process_attributes` and simplify its logic * 🐛 Fix wrong order broke static listeners * ♻️ Use a list comprehension for __cog_listeners__ * ♻️ Extract command update logic to `_update_command` * ♻️ Avoid repeating staticmethod check * ♻️ Import `Generator` & `Mapping` from `collections.abc` instead of `typing` Deprecated since python 3.9, py-cord supports 3.9+ * 🏷️ Fix ignore comments * 📝 Change comment wording --------- Signed-off-by: Paillat <me@paillat.dev> Co-authored-by: Lala Sabathil <lala@pycord.dev> (cherry picked from commit 30912d6)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes made:
SlashCommand.parentBridgeCommand.__bridge__which isTrueBridgeCommandby checking it has anadd_toattribute (BridgeCommandis the only class in py-cord that has such method) with aTypeGuardthat checks it has a__bridge__attribute (which also makes this typed and that's cool)CogMeta.__cog_commands__name_filterto_name_filterand define it outside of__new__to avoid redefining it every time and also avoid assigning a lambda to a variable.bot_orcog_prefixes) to a helper function_validate_name_prefix._process_attributes. Simplify it by changing overengineered checks and simplifying dead code. Renameelem, valuetoattr_name, attr_value_update_command, idem as above.Generator&Mappingfromcollections.abcinstead oftyping(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
examples, ...).
Checklist
type: ignorecomments were used, a comment is also left explaining why.