-
-
Notifications
You must be signed in to change notification settings - Fork 483
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Summary
type
cannot be used to type command types when it should.
Using type
is the preferred way to create type aliases in python 3.12+ instead of assigning to a variable directly.
Related:
- bridge.Context not a valid context typehint #2378
- fix: 🐛 Union type cannot be used in
ctx
. #2611 - https://docs.astral.sh/ruff/rules/non-pep695-type-alias/
Reproduction Steps
Test Code
import os
import logging
from typing import reveal_type
import discord
from dotenv import load_dotenv
from discord.ext import bridge
logging.basicConfig(level=logging.INFO)
load_dotenv()
TOKEN = os.getenv("TOKEN_2")
bot = bridge.Bot(intents=discord.Intents.all(), command_prefix="!")
class MyCustomContext(
bridge.BridgeExtContext
): ... # I want to do this for whatever reason, doing this *is* supported
type Context = MyCustomContext | bridge.BridgeApplicationContext
reveal_type(Context)
class MyCog(discord.Cog):
@bridge.bridge_command()
async def ping(self, ctx: Context, ephemeral: bool = False):
await ctx.respond(f"Pong! {round(bot.latency * 1000)}ms", ephemeral=ephemeral)
bot.add_cog(MyCog())
bot.run(TOKEN)
Expected Results
The code runs.
Actual Results
The code crashes.
Intents
n/a
System Information
n/a
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
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working