Skip to content

TypeError when using Flag with python 3.11+ #2758

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
3 tasks done
Paillat-dev opened this issue Apr 1, 2025 · 0 comments · May be fixed by #2759
Open
3 tasks done

TypeError when using Flag with python 3.11+ #2758

Paillat-dev opened this issue Apr 1, 2025 · 0 comments · May be fixed by #2759
Assignees
Labels
bug Something isn't working
Milestone

Comments

@Paillat-dev
Copy link
Contributor

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.

@Paillat-dev Paillat-dev added the unconfirmed bug A bug report that needs triaging label Apr 1, 2025
@Paillat-dev Paillat-dev linked a pull request Apr 1, 2025 that will close this issue
9 tasks
@Lulalaby Lulalaby added bug Something isn't working and removed unconfirmed bug A bug report that needs triaging labels Apr 1, 2025
@Lulalaby Lulalaby added this to the v2.7 milestone Apr 1, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

2 participants