#Getting error messages from pyright when defining a command group inside a Cog class
1 messages · Page 1 of 1 (latest)
That is, yes.
It seems to be listed as multiple because there is an error for each overload of the group decorator.
Python version, or Pycord?
pycord
I can, but it's 829 lines.
I just installed it with py -3 -m pip install -U py-cord --pre.
print discord.__version__
mhm
2.1.1
I'm migrating from Discord.py.
I have the file on GitHub, it's hard to send it here.
wait
the command seems to work fine when executing, but when editing it storms me with error messages
so can you actually run it fine?
Yes. It's like doing
banana: int = "some string"
Doesn't mean it's all right, though.
this seems more like a problem with your env than the library; perhaps you have conflicting packages?
as far as I can tell, 2.1.1 doesn't inherently cause any issues close to the one you've showcased
I don't have discord.py installed.
That's the only possible conflict I can imagine could happen.
But you may be right. I'll see if I can figure something out.
can you run pip freeze and send the results here?
Parameter 1: type "Concatenate[CogT@group, ContextT@group, P@group]" cannot be assigned to type "Self@Charsheets"
More importantly, in fact
Type "(self: Self@Charsheets, ctx: Context[Unknown]) -> Coroutine[Any, Any, None]" cannot be assigned to type "(Concatenate[CogT@group, ContextT@group, P@group]) -> Coro[T@group]"
Coro = Coroutine[Any, Any, T]
CogT = TypeVar("CogT", bound="Cog")
ContextT = TypeVar("ContextT", bound="Context")
P = ParamSpec("P")
# [...]
# One of the possible types @command/@group takes in as the original function:
Callable[[Concatenate[CogT, ContextT, P]], Coro[Any]]
# And therefore
Callable[[Concatenate[Cog, Context, P]], Coroutine[Any, Any, Any]]
Interesting. Doesn't that disallow other args as an annotation?
E.g. because of
Callable[[Concatenate[ContextT, P]], Coro[Any]],
It's okay if I do:
@commands.group()
async def test_group(ctx):
pass
But not if I do:
@commands.group()
async def test_group(ctx, something: int):
pass
Same error as before.
why are you trying to add other args to a command group?
A group can be called as a command if invoke_without_command=True, no?
And if I can add extra args to a command, should I not be able to do the same to groups, since they end up delegating behavior to command?
I didn't think that was possible
it's always been possible for ext commands, but when testing earlier i don't recall my ide complaining about it
interesting
Coming from discord.py, I use this a lot.
My editor is a mess right now, blowing with errors from me trying to fix the annotations manually.
At least I'm sure it's something in the annotation definitions.
@template_field.command(
name="rename",
aliases=("rn",),
usage="charsheets template field rename <old name> <new name>",
)
async def template_field_rename(
self, ctx, template_name: str, old_name: str, new_name: str
) -> None:
This is an example.
It actually seems to work in py-cord, btw.
yeah ik it works perfectly fine
A distinction I noticed is that Rapptz's discord.py doesn't annotate func.
(in the command decorator)
i can't test it myself because i literally can't repro, but feel free to send a PR on the github if you find an appropriate adjustment
Weird. I'll see if I can do anything about it, although I'm considering just going back and forking discord.py.
fair enough, though can't you just silence this particular error