Specifying multiple datatypes for an argument / Invalid usage of typing.Union
Hi, I was trying to write a discord bot in python, using pycord with slash commands I require a command to take either a string or an object(discord.Member) as an argument. (Datatypes must be specified for proper handling) So function could not be overloaded and optional arguments are out of the question, but an argument should be of either discord.Membre type or string I tried using typing.Union for that, as follows: -------------------------------------- @bot.command( guild_ids=server_ids, name="who", description="Get information about someone's nation" ) async def _who( ctx: discord.ApplicationContext, member: typing.Union[discord.Member, str] ): -------------------------------------- It gives me the following error: -------------------------------------- raise TypeError("Invalid usage of typing.Union") TypeError: Invalid usage of typing.Union -------------------------------------- Any suggestions?