Skip to content

TypeError when using Flag with python 3.11+ #2758

@Paillat-dev

Description

@Paillat-dev

Summary

With python 3.11+, using Flag results in a TypeError about unexpected __init__ arguments

Reproduction Steps

  1. Use python 3.11+
  2. Install pycord master
  3. Use discord.commands.ext.flag

Minimal Reproducible Code

class BasicText(FlagConverter):
    text: str = flag(aliases=["t", "-t"])
    reverse: bool = False

@bot.command()
async def echo(ctx, *, flags: BasicText):
    text = flags.text[::-1] if flags.reverse else flags.text
    await ctx.send(f"Echo: {text}")

Expected Results

The bot to run.

Actual Results

Traceback (most recent call last):
  File "C:\Users\Jérémie\Documents\GitHub\pycord\thing.py", line 23, in <module>
    class BasicText(FlagConverter):
  File "C:\Users\Jérémie\Documents\GitHub\pycord\thing.py", line 24, in BasicText
    text: str = flag(aliases=["t", "-t"])
                ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Jérémie\Documents\GitHub\pycord\discord\ext\commands\flags.py", line 136, in flag
    return Flag(
           ^^^^^
TypeError: Flag.__init__() got an unexpected keyword argument 'name'

Intents

n/a

System Information

  • Python v3.11.9-final
  • py-cord v2.6.1-final
  • aiohttp v3.10.10
  • system info: Windows 10 10.0.26120

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

I will open a pr to fix this.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions