Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

_fallback is not copied by Parameter.replace #10076

Closed
3 tasks done
LyricLy opened this issue Jan 15, 2025 · 0 comments · Fixed by #10077
Closed
3 tasks done

_fallback is not copied by Parameter.replace #10076

LyricLy opened this issue Jan 15, 2025 · 0 comments · Fixed by #10077
Labels
unconfirmed bug A bug report that needs triaging

Comments

@LyricLy
Copy link
Contributor

LyricLy commented Jan 15, 2025

Summary

Using a seemingly innocuous call to replace changes the behaviour of some Parameters.

Reproduction Steps

Call the replace method on any built-in Parameter that uses the hidden _fallback field, such as Author or CurrentChannel.

Minimal Reproducible Code

# only accepts text channels, as expected
@commands.command()
async def foo(ctx, channel: TextChannel = commands.CurrentChannel):
    await ctx.send(x.name)

# accepts any kind of channel, ignoring the annotation
@commands.command()
async def bar(ctx, channel: TextChannel = commands.CurrentChannel.replace(description="A text channel to use.")):
    await ctx.send(x.name)

Expected Results

I expect .replace(description=...), which looks like it should only change the description of the parameter, not to change the behaviour of how it parses.

Actual Results

As the replace method does not copy _fallback, the special behaviour of CurrentChannel to prioritize the annotation in picking a converter is lost.

Intents

guilds, messages, message_content.

System Information

- Python v3.13.1-final
- discord.py v2.4.0-final
- aiohttp v3.10.5
- system info: Linux 6.12.9-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 10 Jan 2025 00:39:41 +0000

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

No response

@LyricLy LyricLy added the unconfirmed bug A bug report that needs triaging label Jan 15, 2025
AbstractUmbra added a commit to AbstractUmbra/discord.py that referenced this issue Jan 15, 2025
Fixes `_fallback` is not copied by `Parameter.replace` Rapptz#10076
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unconfirmed bug A bug report that needs triaging
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant