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:
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
Additional Context
No response
Summary
typecannot be used to type command types when it should.Using
typeis the preferred way to create type aliases in python 3.12+ instead of assigning to a variable directly.Related:
ctx. #2611Reproduction Steps
Test Code
Expected Results
The code runs.
Actual Results
The code crashes.
Intents
n/a
System Information
n/a
Checklist
Additional Context
No response