-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[Commands] Refactor command and group decorators #1818
Merged
Tobotimus
merged 15 commits into
Cog-Creators:V3/develop
from
Tobotimus:V3/refactor_cmd_decorators
Aug 26, 2018
Merged
Changes from 8 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
af4a03f
[V3 Commands] Refactor command and group decorators
Tobotimus c135a50
Add some tests
Tobotimus c62ae58
Merge remote-tracking branch 'remotes/upstream/V3/develop' into V3/re…
Tobotimus 3b128ff
Fix docs reference
Tobotimus 4bbe784
Merge remote-tracking branch 'remotes/upstream/V3/develop' into V3/re…
Tobotimus 489b5c4
Merge branch 'V3/develop' into V3/refactor_cmd_decorators
Tobotimus dd38100
Merge branch 'V3/develop' into V3/refactor_cmd_decorators
Tobotimus 0513b06
Merge branch 'V3/develop' into V3/refactor_cmd_decorators
Tobotimus 109dc01
Merge branch 'V3/develop' into V3/refactor_cmd_decorators
Tobotimus a1a1317
Tweak Group's MRO
Tobotimus bb04c43
Merge branch 'V3/develop' into V3/refactor_cmd_decorators
Tobotimus 2abc96d
Merge branch 'V3/develop' into V3/refactor_cmd_decorators
Tobotimus 8e83f2f
Merge branch 'V3/develop' into V3/refactor_cmd_decorators
Tobotimus fe92d92
Merge branch 'V3/develop' into V3/refactor_cmd_decorators
Tobotimus a4064c4
Merge branch 'V3/develop' into V3/refactor_cmd_decorators
Tobotimus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import pytest | ||
from redbot.core import commands | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def group(): | ||
@commands.group() | ||
async def fixturegroup(*args, **kwargs): | ||
return args, kwargs | ||
|
||
return fixturegroup | ||
|
||
|
||
def is_Command(obj): | ||
return isinstance(obj, commands.Command) | ||
|
||
|
||
def is_Group(obj): | ||
return isinstance(obj, commands.Group) | ||
|
||
|
||
def test_command_decorators(coroutine): | ||
assert is_Command(commands.command(name="cmd")(coroutine)) | ||
assert is_Group(commands.group(name="grp")(coroutine)) | ||
|
||
|
||
def test_group_decorator_methods(group, coroutine): | ||
assert is_Command(group.command(name="cmd")(coroutine)) | ||
assert is_Group(group.group(name="grp")(coroutine)) | ||
|
||
|
||
def test_bot_decorator_methods(red, coroutine): | ||
assert is_Command(red.command(name="cmd")(coroutine)) | ||
assert is_Group(red.group(name="grp")(coroutine)) |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why call our own reference to
BotBase
? I don't see a whole lot of sense in doing thisThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can change it to
discord.ext.commands.bot.BotBase
if you'd like, it wouldn't make a differenceThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could instead subclass
discord.ext.commands.bot.BotBase
and add theGroupMixin
there. It wouldn't be any different to the current setup but would simplifyRedBase
's direct inheritanceThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See here for an example of what I mean, I don't really think its necessary but all of this inheritance stuff is pretty confusing to some, perhaps this makes it a bit simpler? I'm not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, this is probably a better way to show the example