[Commands Module] Improve usability of type hints #3410

Merged
mikeshardmind merged 6 commits from typehint-improvements into V3/develop 2020-01-26 23:54:40 +01:00
mikeshardmind commented 2020-01-19 00:50:39 +01:00 (Migrated from github.com)

Type

  • Bugfix
  • Enhancement
  • New feature

Description of the changes

This does a few things, but this should be safe enough as is.

  1. We don't re-export discord.py modules
  2. We did keep the re-export of any names we haven't replaced.
  3. Added a few Type Aliases
  • DMContext
  • GuildContext
  1. Added a few Converters which look like, and play nice with other type checking
  • UserInputOptional
  • RedOptional
  • Literal
  1. Added a setting to ignore discord.py's special casing of typing.Optional
  • While this is usable for many simple cases, you may want to look at added converter types as alternatives to this setting for more complex argument handling.
### Type - [ ] Bugfix - [X] Enhancement - [ ] New feature ### Description of the changes This does a few things, but this should be safe enough as is. 1. We don't re-export discord.py modules 2. We did keep the re-export of any names we haven't replaced. 3. Added a few Type Aliases - DMContext - GuildContext 4. Added a few Converters which look like, and play nice with other type checking - UserInputOptional - RedOptional - Literal 5. Added a setting to ignore discord.py's special casing of typing.Optional - While this is usable for many simple cases, you may want to look at added converter types as alternatives to this setting for more complex argument handling.
palmtree5 (Migrated from github.com) reviewed 2020-01-19 00:50:39 +01:00
tekulvw (Migrated from github.com) reviewed 2020-01-19 00:50:39 +01:00
Twentysix26 (Migrated from github.com) reviewed 2020-01-19 00:50:39 +01:00
mikeshardmind commented 2020-01-19 01:35:13 +01:00 (Migrated from github.com)

Lying to mypy while shadowing the commands module like this is proving to be problematic

We get a lot of benefits from type analysis if we can get this right, but we may need to not shadow discord.py's commands module anymore.

Lying to mypy while shadowing the commands module like this is proving to be *problematic* We get a lot of benefits from type analysis if we can get this right, but we may need to not shadow discord.py's commands module anymore.
mikeshardmind commented 2020-01-19 02:55:14 +01:00 (Migrated from github.com)

This should no longer be failing, and also not break anyone, but long term we need some more robust handling of this.

And now we're looking at a breaking version anyhow...

~~This should no longer be failing, and also not break anyone, but long term we need some more robust handling of this.~~ And now we're looking at a breaking version anyhow...
mikeshardmind commented 2020-01-19 09:26:53 +01:00 (Migrated from github.com)

So, the strain on cog creators for this is something we can hopefully avoid. I'm putting more effort into doing this in a way which may add marginally to our dep update process, but should be otherwise fine and gain in usability and maintainability.

So, the strain on cog creators for this is something we can hopefully avoid. I'm putting more effort into doing this in a way which may add marginally to our dep update process, but should be otherwise fine and gain in usability and maintainability.
Jackenmen commented 2020-01-19 17:20:47 +01:00 (Migrated from github.com)

I looked to see if there are any names that have disappeared after applying this changes and those would be the module names from discord.ext.commands: bot, cog, cooldowns, core, view
While I think it's not that good to keep those here forever, it would technically be a breaking change, so we might want to keep them here for now and remove later when doing Red 3.3.

I looked to see if there are any names that have disappeared after applying this changes and those would be the module names from discord.ext.commands: `bot`, `cog`, `cooldowns`, `core`, `view` While I think it's not that good to keep those here forever, it would technically be a breaking change, so we might want to keep them here for now and remove later when doing Red 3.3.
mikeshardmind commented 2020-01-19 17:33:33 +01:00 (Migrated from github.com)

sigh okay will add those in later this evening.

*sigh* okay will add those in later this evening.
mikeshardmind commented 2020-01-19 23:44:48 +01:00 (Migrated from github.com)

Technically breaking again.

Scope of breakage is limited to people importing discord.py submodules (not classes/funcs/etc) from redbot.core and people directly using PermissionState.TRANSITIONS and PermissionState.ALLOWED_STATES, and people declaring coroutines using the asyncio.coroutine decorator (we're python 3.8+, please don't be doing this) for use as command objects

Technically breaking again. Scope of breakage is limited to people importing discord.py submodules (not classes/funcs/etc) from redbot.core and people directly using `PermissionState.TRANSITIONS` and `PermissionState.ALLOWED_STATES`, and people declaring coroutines using the asyncio.coroutine decorator (we're python 3.8+, please don't be doing this) for use as command objects
Jackenmen (Migrated from github.com) requested changes 2020-01-20 00:51:28 +01:00
Jackenmen (Migrated from github.com) left a comment

Found few small problems with d.py reimplements and have few small questions.

Also not included in review comments, but do we want to privatize some parts of redbot.core.commands.requires to be able to avoid minor bump when the only changes are in internal stuff?

Found few small problems with d.py reimplements and have few small questions. Also not included in review comments, but do we want to privatize some parts of `redbot.core.commands.requires` to be able to avoid minor bump when the only changes are in internal stuff?
@ -302,0 +309,4 @@
else:
def get_timedelta_converter(
Jackenmen (Migrated from github.com) commented 2020-01-20 00:38:31 +01:00

Why is this branch needed if type hints are exactly the same?

Why is this branch needed if type hints are exactly the same?
@ -302,0 +420,4 @@
.. warning::
This converter class is still provisional.
Jackenmen (Migrated from github.com) commented 2020-01-20 00:38:50 +01:00

Why is this branch needed if type hints are exactly the same?

Why is this branch needed if type hints are exactly the same?
Jackenmen (Migrated from github.com) commented 2020-01-20 00:08:23 +01:00

Why is this not using dot notation?

Why is this not using dot notation?
Jackenmen (Migrated from github.com) commented 2020-01-20 00:08:39 +01:00

Why is this not using dot notation?

Why is this not using dot notation?
Jackenmen (Migrated from github.com) commented 2020-01-20 00:18:43 +01:00

Implementation in d.py seems to have this instead:

            raise dpy_commands.BotMissingRole(item)
Implementation in d.py seems to have this instead: ```suggestion raise dpy_commands.BotMissingRole(item) ```
Jackenmen (Migrated from github.com) commented 2020-01-20 00:19:03 +01:00

Implementation in d.py seems to have this instead:

            raise dpy_commands.BotMissingAnyRole(items)
Implementation in d.py seems to have this instead: ```suggestion raise dpy_commands.BotMissingAnyRole(items) ```
Jackenmen (Migrated from github.com) commented 2020-01-20 00:20:11 +01:00
                if getter(id=item):
```suggestion if getter(id=item): ```
Jackenmen (Migrated from github.com) commented 2020-01-20 00:27:53 +01:00
    return [f"<@{bot.user.id}> ", f"<@!{bot.user.id}> "]
```suggestion return [f"<@{bot.user.id}> ", f"<@!{bot.user.id}> "] ```
Jackenmen (Migrated from github.com) commented 2020-01-20 00:49:19 +01:00

This will make decorators stop working with generator-based coros (@asyncio.coroutine).
I'm completely fine with this, especially that they're deprecated since Python 3.8 but I think this is technically also a breaking change which should be mentioned as part of the warning just in case.

This will make decorators stop working with generator-based coros (`@asyncio.coroutine`). I'm completely fine with this, especially that they're deprecated since Python 3.8 but I think this is technically also a breaking change which should be mentioned as part of the warning just in case.
mikeshardmind (Migrated from github.com) reviewed 2020-01-20 15:38:04 +01:00
mikeshardmind (Migrated from github.com) commented 2020-01-20 15:38:03 +01:00

Intentional. Mypy doesn't appreciate dynamic access to attributes which aren't declared

Intentional. Mypy doesn't appreciate dynamic access to attributes which aren't declared
mikeshardmind (Migrated from github.com) reviewed 2020-01-20 15:40:21 +01:00
@ -302,0 +309,4 @@
else:
def get_timedelta_converter(
mikeshardmind (Migrated from github.com) commented 2020-01-20 15:40:21 +01:00

type hints are the same, but there's a dynamic class declaration inside which mypy doesn't allow. For the sake of people using this, making it not appear dynamic since external to the function, the typing is fine.

type hints are the same, but there's a dynamic class declaration inside which mypy doesn't allow. For the sake of people using this, making it not appear dynamic since external to the function, the typing is fine.
Jackenmen (Migrated from github.com) reviewed 2020-01-20 16:08:15 +01:00
Jackenmen (Migrated from github.com) left a comment
No description provided.
Should be ready to go now.
mikeshardmind commented 2020-01-20 16:22:59 +01:00 (Migrated from github.com)

K, this is on hold till the discord.py version bump then, and we'll do a wrap up with anything we have ready around then.

K, this is on hold till the discord.py version bump then, and we'll do a wrap up with anything we have ready around then.
mikeshardmind commented 2020-01-21 03:07:28 +01:00 (Migrated from github.com)

rebased over other newer changes.

rebased over other newer changes.
Jackenmen commented 2020-01-22 15:12:15 +01:00 (Migrated from github.com)

I didn't look much at callback definition, but this breaks:

from redbot.core import commands
from typing import Optional

@commands.is_owner()
@commands.command(ignore_optional_for_conversion=True)
async def somecom(ctx: commands.Context, number: Optional[int]) -> None:
    await ctx.send(f"hello {number}")

bot.add_command(somecom)

With traceback:

Traceback (most recent call last):
  File "C:\Users\Jakub\OneDrive\Dokumenty\Red-DiscordBot\redbot\core\dev_commands.py", line 171, in _eval
    result = await func()
  File "<string>", line 9, in func
  File "C:\Users\Jakub\OneDrive\Dokumenty\Red-DiscordBot\.venv\lib\site-packages\discord\ext\commands\core.py", line 1241, in decorator
    return cls(func, name=name, **attrs)
  File "C:\Users\Jakub\OneDrive\Dokumenty\Red-DiscordBot\redbot\core\commands\commands.py", line 248, in __init__
    super().__init__(*args, **kwargs)
  File "C:\Users\Jakub\OneDrive\Dokumenty\Red-DiscordBot\redbot\core\commands\commands.py", line 82, in __init__
    super().__init__(*args, **kwargs)
  File "C:\Users\Jakub\OneDrive\Dokumenty\Red-DiscordBot\.venv\lib\site-packages\discord\ext\commands\core.py", line 207, in __init__
    self.callback = func
  File "C:\Users\Jakub\OneDrive\Dokumenty\Red-DiscordBot\redbot\core\commands\commands.py", line 314, in callback
    args = vtype.__args__
AttributeError: '_SpecialForm' object has no attribute '__args__'
I didn't look much at `callback` definition, but this breaks: ```py from redbot.core import commands from typing import Optional @commands.is_owner() @commands.command(ignore_optional_for_conversion=True) async def somecom(ctx: commands.Context, number: Optional[int]) -> None: await ctx.send(f"hello {number}") bot.add_command(somecom) ``` With traceback: ```py Traceback (most recent call last): File "C:\Users\Jakub\OneDrive\Dokumenty\Red-DiscordBot\redbot\core\dev_commands.py", line 171, in _eval result = await func() File "<string>", line 9, in func File "C:\Users\Jakub\OneDrive\Dokumenty\Red-DiscordBot\.venv\lib\site-packages\discord\ext\commands\core.py", line 1241, in decorator return cls(func, name=name, **attrs) File "C:\Users\Jakub\OneDrive\Dokumenty\Red-DiscordBot\redbot\core\commands\commands.py", line 248, in __init__ super().__init__(*args, **kwargs) File "C:\Users\Jakub\OneDrive\Dokumenty\Red-DiscordBot\redbot\core\commands\commands.py", line 82, in __init__ super().__init__(*args, **kwargs) File "C:\Users\Jakub\OneDrive\Dokumenty\Red-DiscordBot\.venv\lib\site-packages\discord\ext\commands\core.py", line 207, in __init__ self.callback = func File "C:\Users\Jakub\OneDrive\Dokumenty\Red-DiscordBot\redbot\core\commands\commands.py", line 314, in callback args = vtype.__args__ AttributeError: '_SpecialForm' object has no attribute '__args__' ```
Jackenmen commented 2020-01-22 16:10:08 +01:00 (Migrated from github.com)

I can't get commands.Literal to work, example code that doesn't work for me:

from redbot.core import commands
from redbot.core.commands import Literal

@commands.is_owner()
@commands.command()
async def somecom(ctx: commands.Context, test: Literal["foo", "bar"]) -> None:
    await ctx.send(test)

bot.add_command(somecom)

All I get when using [p]somecom foo is Converting to "Literal" failed for parameter "test".

Edit: I was able to get this to work after subclassing Literal class from commands.Converter.
Also, this will have an unexpected behavior when only one argument is passed to Literal - you get a string not tuple passed to __class_getitem__ then which means you're checking if passed arg is a substring.

I can't get `commands.Literal` to work, example code that doesn't work for me: ```py from redbot.core import commands from redbot.core.commands import Literal @commands.is_owner() @commands.command() async def somecom(ctx: commands.Context, test: Literal["foo", "bar"]) -> None: await ctx.send(test) bot.add_command(somecom) ``` All I get when using `[p]somecom foo` is `Converting to "Literal" failed for parameter "test".` Edit: I was able to get this to work after subclassing `Literal` class from `commands.Converter`. Also, this will have an unexpected behavior when only one argument is passed to `Literal` - you get a string not tuple passed to `__class_getitem__` then which means you're checking if passed arg is a substring.
Jackenmen (Migrated from github.com) requested changes 2020-01-22 21:20:24 +01:00
Jackenmen (Migrated from github.com) commented 2020-01-22 21:07:18 +01:00

You only import the converter but didn't use it.

You only import the converter but didn't use it.
Jackenmen (Migrated from github.com) commented 2020-01-22 21:08:39 +01:00

This hasn't been documented.

This hasn't been documented.
@ -254,7 +265,7 @@ class Context(commands.Context):
return pattern.sub(f"@{me.display_name}", self.prefix)
Jackenmen (Migrated from github.com) commented 2020-01-22 21:09:20 +01:00

These 2 classes aren't documented (not specified in framework_commands.rst file and placed under if TYPE_CHECKING).

These 2 classes aren't documented (not specified in `framework_commands.rst` file and placed under `if TYPE_CHECKING`).
Jackenmen (Migrated from github.com) commented 2020-01-22 21:09:48 +01:00
    .. warning::
        This will be removed in version 3.4.
```suggestion .. warning:: This will be removed in version 3.4. ```
@ -149,2 +170,4 @@
.. warning::
This will be removed in version 3.4.
"""
Jackenmen (Migrated from github.com) commented 2020-01-22 21:11:47 +01:00

This suggestion and the one below can only be applied together as I changed the order.

        .. warning::
            This converter class is still provisional.
This suggestion and the one below can only be applied together as I changed the order. ```suggestion .. warning:: This converter class is still provisional. ```
Jackenmen (Migrated from github.com) commented 2020-01-22 21:13:41 +01:00

This suggestion and the one above can only be applied together as I changed the order.
Also, if ignore_optional_for_conversion gets documented, this should be a proper reference to that option.

        .. seealso::
            The ``ignore_optional_for_conversion`` option of commands.
This suggestion and the one above can only be applied together as I changed the order. Also, if `ignore_optional_for_conversion` gets documented, this should be a proper reference to that option. ```suggestion .. seealso:: The ``ignore_optional_for_conversion`` option of commands. ```
Jackenmen (Migrated from github.com) commented 2020-01-22 21:14:36 +01:00

This isn't documented because of the place it is in (under if TYPE_CHECKING:)

This isn't documented because of the place it is in (under `if TYPE_CHECKING:`)
Jackenmen (Migrated from github.com) commented 2020-01-22 21:14:57 +01:00
        This can be used instead of `typing.Optional`
```suggestion This can be used instead of `typing.Optional` ```
Jackenmen (Migrated from github.com) commented 2020-01-22 21:15:14 +01:00
        to avoid discord.py special casing the conversion behavior.
```suggestion to avoid discord.py special casing the conversion behavior. ```
Jackenmen (Migrated from github.com) commented 2020-01-22 21:15:42 +01:00
        .. warning::
            This converter class is still provisional.
```suggestion .. warning:: This converter class is still provisional. ```
Jackenmen (Migrated from github.com) commented 2020-01-22 21:16:01 +01:00
        .. warning::
            This converter class is still provisional.
```suggestion .. warning:: This converter class is still provisional. ```
Jackenmen (Migrated from github.com) reviewed 2020-01-22 21:23:42 +01:00
Jackenmen (Migrated from github.com) left a comment

Now these are just me being picky, feel free to ignore those, but it's just a matter of merging suggestions.

Now these are just me being picky, feel free to ignore those, but it's just a matter of merging suggestions.
@ -149,2 +170,4 @@
.. warning::
This will be removed in version 3.4.
"""
Jackenmen (Migrated from github.com) commented 2020-01-22 21:21:57 +01:00
        This can be used as a converter for `typing.Literal`.
```suggestion This can be used as a converter for `typing.Literal`. ```
Jackenmen (Migrated from github.com) commented 2020-01-22 21:22:11 +01:00
        In a type checking context it is `typing.Literal`.
```suggestion In a type checking context it is `typing.Literal`. ```
Jackenmen (Migrated from github.com) commented 2020-01-22 21:22:19 +01:00
        In a runtime context, it's a converter which only matches the literals it was given.
```suggestion In a runtime context, it's a converter which only matches the literals it was given. ```
Jackenmen (Migrated from github.com) commented 2020-01-22 21:22:46 +01:00
        treats `typing.Optional`, but the type should not be equivalent to
```suggestion treats `typing.Optional`, but the type should not be equivalent to ```
Jackenmen (Migrated from github.com) reviewed 2020-01-22 21:50:28 +01:00
Jackenmen (Migrated from github.com) left a comment

Two more nitpicks, might as well add them to the list 😛

Two more nitpicks, might as well add them to the list 😛
Jackenmen (Migrated from github.com) commented 2020-01-22 21:46:52 +01:00
    Note: Core usage of this has been replaced with `DictConverter` use instead.
```suggestion Note: Core usage of this has been replaced with `DictConverter` use instead. ```
@ -149,2 +170,4 @@
.. warning::
This will be removed in version 3.4.
"""
Jackenmen (Migrated from github.com) commented 2020-01-22 21:47:56 +01:00
        ``typing.Union[DesiredType, None]`` for type checking.
```suggestion ``typing.Union[DesiredType, None]`` for type checking. ```
Jackenmen commented 2020-01-23 00:18:59 +01:00 (Migrated from github.com)

Soooo, there's a workaround for the issue with RedOptional and Literal being exported incorrectly...
Re-exporting when importing (from typing import Optional as RedOptional) and using if not TYPE_CHECKING: to define implementation at runtime would make it work properly.

Soooo, there's a workaround for the issue with `RedOptional` and `Literal` being exported incorrectly... Re-exporting when importing (`from typing import Optional as RedOptional`) and using `if not TYPE_CHECKING:` to define implementation at runtime would make it work properly.
Jackenmen commented 2020-01-24 03:21:01 +01:00 (Migrated from github.com)

Just FYI, I reverted changes to kickban.py, I didn't actually plan to do this for you but my tools betrayed me... Ekhm, anyhow, changes to that file don't really fit into this PR after it no longer is replaced with UserInputOptional + #3437 will get rid of the cast that I think you wanted to get rid of.

Still planning to do the actual review tomorrow 😄

Just FYI, I reverted changes to `kickban.py`, I didn't actually plan to do this for you but my tools betrayed me... Ekhm, anyhow, changes to that file don't really fit into this PR after it no longer is replaced with `UserInputOptional` + #3437 will get rid of the `cast` that I think you wanted to get rid of. Still planning to do the actual review tomorrow 😄
mikeshardmind commented 2020-01-24 03:33:35 +01:00 (Migrated from github.com)

No worries, I left the PR editable intentionally, sound reversion if it simplifies things.

No worries, I left the PR editable intentionally, sound reversion if it simplifies things.
Jackenmen (Migrated from github.com) requested changes 2020-01-24 20:09:04 +01:00
Jackenmen (Migrated from github.com) left a comment

If you care about fixing func.__requires* stuff in this PR, feel free to but I didn't find it important enough to put review comments on stuff that needs setattr() use as it's not important to have it in this PR.

If you care about fixing `func.__requires*` stuff in this PR, feel free to but I didn't find it important enough to put review comments on stuff that needs `setattr()` use as it's not important to have it in this PR.
Jackenmen (Migrated from github.com) commented 2020-01-24 19:31:09 +01:00

mypy screams about the redefinitions of those later in the code ("All conditional function variants must have identical signatures"), one possible solution for this would be putting those imports here under if not TYPE_CHECKING

mypy screams about the redefinitions of those later in the code ("All conditional function variants must have identical signatures"), one possible solution for this would be putting those imports here under `if not TYPE_CHECKING`
Jackenmen (Migrated from github.com) commented 2020-01-24 19:33:20 +01:00

Do we want to define our own versions of those instead of just putting typed variants under if TYPE_CHECKING and re-exporting the ones from d.py?

Do we want to define our own versions of those instead of just putting typed variants under `if TYPE_CHECKING` and re-exporting the ones from d.py?
mikeshardmind (Migrated from github.com) reviewed 2020-01-24 20:20:36 +01:00
mikeshardmind (Migrated from github.com) commented 2020-01-24 20:20:35 +01:00

These ones aren't conditionally defined.

These ones aren't conditionally defined.
mikeshardmind (Migrated from github.com) reviewed 2020-01-24 20:21:33 +01:00
mikeshardmind (Migrated from github.com) commented 2020-01-24 20:21:32 +01:00

Conditional import is fine here. It may be ugly, but the point is for this to work for our users and devs, if a little bit more ugly importing in this module is needed for it, that's fine.

Conditional import is fine here. It may be ugly, but the point is for this to work for our users and devs, if a little bit more ugly importing in this module is needed for it, that's fine.
Jackenmen (Migrated from github.com) requested changes 2020-01-25 00:54:09 +01:00
Jackenmen (Migrated from github.com) left a comment

Aside from stuff I put in review comments, we also need to type hint decorators in requires - bot_has_permissions, has_permissions, is_owner, ...
And it would also be good to type-hint @commands.command()/@commands.group() as even with d.py stubs we still end up with our own deco untyped. But I don't remember full story on why you removed the type hints from those in first place so I am probably missing something here.

There are also some things that I want to ask about but that are gonna be easier to discuss in discord.

Aside from stuff I put in review comments, we also need to type hint decorators in `requires` - `bot_has_permissions`, `has_permissions`, `is_owner`, ... And it would also be good to type-hint `@commands.command()`/`@commands.group()` as even with d.py stubs we still end up with our own deco untyped. But I don't remember full story on why you removed the type hints from those in first place so I am probably missing something here. There are also some things that I want to ask about but that are gonna be easier to discuss in discord.
Jackenmen (Migrated from github.com) commented 2020-01-24 23:21:05 +01:00
    def get_command(self, name: str) -> Optional[commands.Command]:
```suggestion def get_command(self, name: str) -> Optional[commands.Command]: ```
Jackenmen (Migrated from github.com) commented 2020-01-24 23:21:19 +01:00
    def get_cog(self, name: str) -> Optional[commands.Cog]:
```suggestion def get_cog(self, name: str) -> Optional[commands.Cog]: ```
Jackenmen (Migrated from github.com) commented 2020-01-24 23:23:20 +01:00

This needs cast or assert.

This needs cast or assert.
Jackenmen (Migrated from github.com) commented 2020-01-24 23:23:29 +01:00

This needs cast or assert.

This needs cast or assert.
@ -263,3 +274,63 @@ class Context(commands.Context):
return self.guild.me
Jackenmen (Migrated from github.com) commented 2020-01-24 23:37:44 +01:00
        def me(self) -> discord.ClientUser:
```suggestion def me(self) -> discord.ClientUser: ```
@ -138,17 +160,18 @@ class APIToken(discord.ext.commands.Converter):
This will parse the input argument separating the key value pairs into a
Jackenmen (Migrated from github.com) commented 2020-01-24 23:39:32 +01:00
    This will split the argument by a space, comma, or semicolon and return a dict
```suggestion This will split the argument by a space, comma, or semicolon and return a dict ```
@ -162,140 +185,262 @@ class APIToken(discord.ext.commands.Converter):
return result
Jackenmen (Migrated from github.com) commented 2020-01-24 23:42:22 +01:00

Not part of PR but since I noticed it, figured I can mention it 🤷‍♂

            in specific units. The units you can choose to provide are the same as the
Not part of PR but since I noticed it, figured I can mention it 🤷‍♂ ```suggestion in specific units. The units you can choose to provide are the same as the ```
Jackenmen (Migrated from github.com) commented 2020-01-24 23:42:38 +01:00

Not part of PR but since I noticed it, figured I can mention it 🤷‍♂

            in specific units. The units you can choose to provide are the same as the
Not part of PR but since I noticed it, figured I can mention it 🤷‍♂ ```suggestion in specific units. The units you can choose to provide are the same as the ```
Jackenmen (Migrated from github.com) commented 2020-01-24 23:44:26 +01:00
            We're aware and looking into improving this.
```suggestion We're aware and looking into improving this. ```
Jackenmen (Migrated from github.com) commented 2020-01-24 23:52:11 +01:00

Would be convenient to have this reference the option for ease of navigation. I checked and this will get referenced properly by sphinx without adding anything.

            The `ignore_optional_for_conversion` option of commands.
Would be convenient to have this reference the option for ease of navigation. I checked and this will get referenced properly by sphinx without adding anything. ```suggestion The `ignore_optional_for_conversion` option of commands. ```
Jackenmen (Migrated from github.com) commented 2020-01-25 00:02:02 +01:00

This type is supposed to represent both commands.Command and Callable[..., Awaitable[Any]]], otherwise developers are gonna run into issues when they use check decorators before @commands.command() so I think this shouldn't be left like that unless I'm missing something here.

This type is supposed to represent both `commands.Command` and `Callable[..., Awaitable[Any]]]`, otherwise developers are gonna run into issues when they use check decorators before `@commands.command()` so I think this shouldn't be left like that unless I'm missing something here.
@ -248,13 +252,18 @@ PermState.TRANSITIONS = {
PermState.ACTIVE_DENY: (False, PermState.ACTIVE_DENY),
},
Jackenmen (Migrated from github.com) commented 2020-01-25 00:20:35 +01:00

Since this is supposed to be public, shouldn't it be added to __all__?

Since this is supposed to be public, shouldn't it be added to `__all__`?
Jackenmen (Migrated from github.com) commented 2020-01-25 00:20:39 +01:00

Since this is supposed to be public, shouldn't it be added to __all__?

Since this is supposed to be public, shouldn't it be added to `__all__`?
Jackenmen (Migrated from github.com) commented 2020-01-25 00:21:02 +01:00

Since this is supposed to be public, shouldn't it be added to __all__?

Since this is supposed to be public, shouldn't it be added to `__all__`?
mikeshardmind commented 2020-01-25 06:02:58 +01:00 (Migrated from github.com)

Resolved most of the remaining issues, some are small things that we can (and will) continue improving on. The commit has been rebased down to a single commit over V3/develop for sanity purposes with how many revisions this entailed.

Resolved most of the remaining issues, some are small things that we can (and will) continue improving on. The commit has been rebased down to a single commit over V3/develop for sanity purposes with how many revisions this entailed.
Jackenmen (Migrated from github.com) reviewed 2020-01-25 14:02:12 +01:00
@ -254,7 +265,7 @@ class Context(commands.Context):
return pattern.sub(f"@{me.display_name}", self.prefix)
Jackenmen (Migrated from github.com) commented 2020-01-25 14:02:12 +01:00
    def me(self) -> Union[discord.ClientUser, discord.Member]:
```suggestion def me(self) -> Union[discord.ClientUser, discord.Member]: ```
Jackenmen (Migrated from github.com) reviewed 2020-01-25 14:06:03 +01:00
Jackenmen (Migrated from github.com) left a comment
No description provided.
Gonna go ahead and approve, there's one suggestion above which I wanted to just commit myself, but I don't have permissions to push to this repository, ping me on discord and I can reapprove if my review gets marked as stale because of committing that. Would love to get some feedback on this comment too but it's not something that makes it worth to hold off the approval: https://github.com/Cog-Creators/Red-DiscordBot/pull/3410#discussion_r370879326
mikeshardmind (Migrated from github.com) reviewed 2020-01-25 18:58:42 +01:00
mikeshardmind (Migrated from github.com) commented 2020-01-25 18:58:42 +01:00

I've put this back for now, but I'm not entirely sure we should be encouraging decorator orders which don't stack logically as these end up doing assignments to function objects which gets much more difficult to write good typing for.

I've put this back for now, but I'm not entirely sure we should be encouraging decorator orders which don't stack logically as these end up doing assignments to function objects which gets much more difficult to write good typing for.
Jackenmen (Migrated from github.com) reviewed 2020-01-25 19:07:49 +01:00
Jackenmen (Migrated from github.com) approved these changes 2020-01-26 23:37:43 +01:00
Sign in to join this conversation.
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot!3410
No description provided.