Skip to content

Conversation

@sobolevn
Copy link
Member

This is a bit hacky, but it does solve the problem :)

Closes #13518

@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check the primer output? It looks like there are some lines that used to error that have no errors... is that a good thing?

@sobolevn
Copy link
Member Author

Yes, I am looking at it right now!

discord/app_commands/commands.py:113: error: The first argument to Callable must be a list of types, parameter specification, or "..."

Hm 🤔
Code: Callable[Concatenate[GroupT, 'Interaction', P], Coro[T]]
Link: https://github.com/Rapptz/discord.py/blob/7c1dffbf9d62279960a3618676a2c3972cd55207/discord/app_commands/commands.py#L112-L115

Looks like unbound P is not reported now.

discord/ext/commands/hybrid.py:85: error: The first argument to Callable must be a list of types, parameter specification, or "..."

Code: Callable[Concatenate[CogT, ContextT, P], Coro[T]]
Link: https://github.com/Rapptz/discord.py/blob/7c1dffbf9d62279960a3618676a2c3972cd55207/discord/ext/commands/hybrid.py#L85

Unbound P is not reported.

I will fix it and write extra tests tomorrow 🌆

@sobolevn
Copy link
Member Author

sobolevn commented Aug 27, 2022

Actually, it works better now in my opinion.
Here's the real output:
Снимок экрана 2022-08-27 в 9 18 44

Code:

from typing_extensions import Concatenate, ParamSpec
from typing import Callable

P = ParamSpec('P')

X = Callable[Concatenate[int, P], None]

It is still not ideal, because of The last parameter to Concatenate needs to be a ParamSpec, but this is out of scope of this PR. I will fix it in the next one.

@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

discord.py (https://github.com/Rapptz/discord.py)
- discord/app_commands/commands.py:113: error: The first argument to Callable must be a list of types, parameter specification, or "..."
- discord/app_commands/commands.py:113: note: See https://mypy.readthedocs.io/en/stable/kinds_of_types.html#callable-types-and-lambdas
- discord/app_commands/commands.py:114: error: The first argument to Callable must be a list of types, parameter specification, or "..."
- discord/app_commands/commands.py:114: note: See https://mypy.readthedocs.io/en/stable/kinds_of_types.html#callable-types-and-lambdas
+ discord/app_commands/commands.py:672: error: Item "function" of "Union[Callable[[VarArg(Any), KwArg(Any)], Any], Callable[[VarArg(Any), KwArg(Any)], Any]]" has no attribute "__self__"
+ discord/app_commands/commands.py:673: error: Item "function" of "Union[Callable[[VarArg(Any), KwArg(Any)], Any], Callable[[VarArg(Any), KwArg(Any)], Any]]" has no attribute "__func__"
- discord/app_commands/commands.py:2408: error: Item "function" of "Union[Any, Callable[[Interaction, Member], Coroutine[Any, Any, Any]], Callable[[Interaction, User], Coroutine[Any, Any, Any]], Callable[[Interaction, Message], Coroutine[Any, Any, Any]]]" has no attribute "__discord_app_commands_checks__"
+ discord/app_commands/commands.py:2408: error: Item "function" of "Union[Callable[[VarArg(Any), KwArg(Any)], Any], Callable[[Interaction, Member], Coroutine[Any, Any, Any]], Callable[[Interaction, User], Coroutine[Any, Any, Any]], Callable[[Interaction, Message], Coroutine[Any, Any, Any]]]" has no attribute "__discord_app_commands_checks__"
- discord/app_commands/commands.py:2410: error: Item "function" of "Union[Any, Callable[[Interaction, Member], Coroutine[Any, Any, Any]], Callable[[Interaction, User], Coroutine[Any, Any, Any]], Callable[[Interaction, Message], Coroutine[Any, Any, Any]]]" has no attribute "__discord_app_commands_checks__"
+ discord/app_commands/commands.py:2410: error: Item "function" of "Union[Callable[[VarArg(Any), KwArg(Any)], Any], Callable[[Interaction, Member], Coroutine[Any, Any, Any]], Callable[[Interaction, User], Coroutine[Any, Any, Any]], Callable[[Interaction, Message], Coroutine[Any, Any, Any]]]" has no attribute "__discord_app_commands_checks__"
- discord/ext/commands/hybrid.py:85: error: The first argument to Callable must be a list of types, parameter specification, or "..."
- discord/ext/commands/hybrid.py:85: note: See https://mypy.readthedocs.io/en/stable/kinds_of_types.html#callable-types-and-lambdas
- discord/ext/commands/hybrid.py:86: error: The first argument to Callable must be a list of types, parameter specification, or "..."
- discord/ext/commands/hybrid.py:86: note: See https://mypy.readthedocs.io/en/stable/kinds_of_types.html#callable-types-and-lambdas
- discord/ext/commands/hybrid.py:793: note:          def command(self, name: Union[str, locale_str] = ..., *args: Any, with_app_command: bool = ..., **kwargs: Any) -> Callable[[Union[Any, Any]], HybridCommand[CogT, P2, U]]
+ discord/ext/commands/hybrid.py:793: note:          def command(self, name: Union[str, locale_str] = ..., *args: Any, with_app_command: bool = ..., **kwargs: Any) -> Callable[[Union[Callable[[VarArg(Any), KwArg(Any)], Any], Callable[[VarArg(Any), KwArg(Any)], Any]]], HybridCommand[CogT, P2, U]]
- discord/ext/commands/hybrid.py:817: note:          def group(self, name: Union[str, locale_str] = ..., *args: Any, with_app_command: bool = ..., **kwargs: Any) -> Callable[[Union[Any, Any]], HybridGroup[CogT, P2, U]]
+ discord/ext/commands/hybrid.py:817: note:          def group(self, name: Union[str, locale_str] = ..., *args: Any, with_app_command: bool = ..., **kwargs: Any) -> Callable[[Union[Callable[[VarArg(Any), KwArg(Any)], Any], Callable[[VarArg(Any), KwArg(Any)], Any]]], HybridGroup[CogT, P2, U]]

@sobolevn sobolevn requested a review from hauntsaninja August 29, 2022 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(🐞) Bad error message when using Concatenate incorrectly

2 participants