#Getting error messages from pyright when defining a command group inside a Cog class

1 messages · Page 1 of 1 (latest)

nocturne schooner
#

is that the full error

steady flame
#

That is, yes.

#

It seems to be listed as multiple because there is an error for each overload of the group decorator.

nocturne schooner
#

just in case, can you show the full file

#

and what version is this

steady flame
#

Python version, or Pycord?

nocturne schooner
#

pycord

steady flame
nocturne schooner
#

ehh go for it

#

also, that error is weirdly hard to read...?

steady flame
nocturne schooner
#

print discord.__version__

steady flame
#

I did python --version instead.

#

Python 3.10.6

#

Oh mb

#

You want the discord one

nocturne schooner
#

mhm

steady flame
#

2.1.1

#

I have the file on GitHub, it's hard to send it here.

nocturne schooner
#

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?

steady flame
#

Yes. It's like doing

banana: int = "some string"
#

Doesn't mean it's all right, though.

nocturne schooner
#

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

steady flame
#

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.

cosmic lotus
#

can you run pip freeze and send the results here?

steady flame
#

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]"

steady flame
#
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.

cosmic lotus
#

why are you trying to add other args to a command group?

steady flame
#

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?

cosmic lotus
#

I didn't think that was possible

nocturne schooner
#

it's always been possible for ext commands, but when testing earlier i don't recall my ide complaining about it

#

interesting

steady flame
#

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.

nocturne schooner
#

yeah ik it works perfectly fine

steady flame
#

A distinction I noticed is that Rapptz's discord.py doesn't annotate func.

#

(in the command decorator)

nocturne schooner
#

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

steady flame
#

Weird. I'll see if I can do anything about it, although I'm considering just going back and forking discord.py.

nocturne schooner
#

fair enough, though can't you just silence this particular error

steady flame
#

I can.

#

Problem is

#

I have an error for each group

#

and for each subcommand defined through a group