pycord
pycord copied to clipboard
Confusing error for typed func passed to bridge_command
Summary
Error raised when a typed function is used with the @bridge_command decorator should be fixed
Reproduction Steps
Recently, I have been using the bridge_command decorator to avoid code duplication and have struck upon an interesting error message being raised when I use from __future__ import annotations
.
I have installed py-cord through pip install -U py-cord
with python3 -c "import discord; print(f'{discord.__version__=}, {discord.__title__=}')
returning "discord.version='2.1.1', discord.title='pycord'"
When I use functions with the future annotations, I seem to get a strange error on the line I defined the function:
Exception has occurred: AttributeError 'str' object has no attribute 'name'
Although this may not be a bug, not experienced enough with py-cord to know if such typing is an internal problem, the error itself gives no hints on its origin. In no way does it aid in identifying the type hints used as an issue, which is my main highlight.
I have attached the minimal reproducible code below
Minimal Reproducible Code
from __future__ import annotations
import discord
from discord.ext import bridge
bot = bridge.Bot(command_prefix="$", intents=discord.Intents.default())
@bot.bridge_command()
async def test(ctx, num: int):
await ctx.send(f"__test__ {num=}")
Expected Results
The program runs and does nothing, as no call to bot.run
was used
Actual Results

Stack trace using pretty_traceback:
Aliases for entries in sys.path:
Intents
discord.Intents.default()
System Information
- Python v3.10.3-final
- py-cord v2.1.1-final
- aiohttp v3.7.4.post0
- system info: Darwin 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 20:57:23 PDT 2022; root:xnu-8020.121.3~2/RELEASE_ARM64_T8110
Checklist
- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.
Additional Context
No response
https://guide.pycord.dev/extensions/bridge/
I have read that page (which is the only reason I am using bridge commands)
They do not use from __future__ import annotations
however, which I would like to use but is not a requirement
The issue I am reporting is the strange error name, which gives very little hint into the nature of the problem
If you got that error, typing would not come to mind even though that is the reason it appears (or so I have found through experimentation)
Try upgrading to 2.2.2 and see if the issue is resolved
Hi, I just stumbled upon this problem with 2.3.2, so its still affecting 2.2.2 and newer.
C:\Users\lemon>python -m discord --version
C:\Python\Python311\Lib\site-packages\discord\__main__.py:47: DeprecationWarning: VersionInfo.releaselevel is deprecated since version 2.3, consider using release_level instead.
"- py-cord v{0.major}.{0.minor}.{0.micro}-{0.releaselevel}".format(version_info)
C:\Python\Python311\Lib\site-packages\discord\__main__.py:49: DeprecationWarning: VersionInfo.releaselevel is deprecated since version 2.3, consider using release_level instead.
if version_info.releaselevel != "final":
- Python v3.11.1-final
- py-cord v2.3.2-final
- aiohttp v3.8.3
- system info: Windows 10 10.0.22621
C:\Users\lemon>pip show py-cord
Name: py-cord
Version: 2.3.2
Summary: A Python wrapper for the Discord API
Home-page:
Author: Pycord Development
Author-email:
License: MIT
Location: C:\Python\Python311\Lib\site-packages
Requires: aiohttp
Required-by: lemonbot