mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-08 02:43:01 +00:00
Normalize type formatting in TypeError
Normalize most mixed usages of `__class__`, `__class__!r`, `__class__.__name__!r` to the standard form of `__class__.__name__`
This commit is contained in:
@ -1850,7 +1850,7 @@ class Group:
|
||||
"""
|
||||
|
||||
if not isinstance(command, (Command, Group)):
|
||||
raise TypeError(f'expected Command or Group not {command.__class__!r}')
|
||||
raise TypeError(f'expected Command or Group not {command.__class__.__name__}')
|
||||
|
||||
if isinstance(command, Group) and self.parent is not None:
|
||||
# In a tree like so:
|
||||
|
@ -468,7 +468,7 @@ class Choice(Generic[ChoiceT]):
|
||||
return AppCommandOptionType.string
|
||||
else:
|
||||
raise TypeError(
|
||||
f'invalid Choice value type given, expected int, str, or float but received {self.value.__class__!r}'
|
||||
f'invalid Choice value type given, expected int, str, or float but received {self.value.__class__.__name__}'
|
||||
)
|
||||
|
||||
async def get_translated_payload(self, translator: Translator) -> Dict[str, Any]:
|
||||
|
@ -528,7 +528,7 @@ else:
|
||||
|
||||
def __class_getitem__(cls, items) -> _TransformMetadata:
|
||||
if not isinstance(items, tuple):
|
||||
raise TypeError(f'expected tuple for arguments, received {items.__class__!r} instead')
|
||||
raise TypeError(f'expected tuple for arguments, received {items.__class__.__name__} instead')
|
||||
|
||||
if len(items) != 2:
|
||||
raise TypeError(f'Transform only accepts exactly two arguments')
|
||||
@ -540,7 +540,7 @@ else:
|
||||
raise TypeError(f'second argument of Transform must be a Transformer class not {transformer!r}')
|
||||
transformer = transformer()
|
||||
elif not isinstance(transformer, Transformer):
|
||||
raise TypeError(f'second argument of Transform must be a Transformer not {transformer.__class__!r}')
|
||||
raise TypeError(f'second argument of Transform must be a Transformer not {transformer.__class__.__name__}')
|
||||
|
||||
return transformer
|
||||
|
||||
@ -571,7 +571,7 @@ else:
|
||||
|
||||
def __class_getitem__(cls, obj) -> _TransformMetadata:
|
||||
if not isinstance(obj, tuple):
|
||||
raise TypeError(f'expected tuple for arguments, received {obj.__class__!r} instead')
|
||||
raise TypeError(f'expected tuple for arguments, received {obj.__class__.__name__} instead')
|
||||
|
||||
if len(obj) == 2:
|
||||
obj = (*obj, None)
|
||||
|
@ -346,7 +346,7 @@ class CommandTree(Generic[ClientT]):
|
||||
self._context_menus.update(current)
|
||||
return
|
||||
elif not isinstance(command, (Command, Group)):
|
||||
raise TypeError(f'Expected an application command, received {command.__class__!r} instead')
|
||||
raise TypeError(f'Expected an application command, received {command.__class__.__name__} instead')
|
||||
|
||||
# todo: validate application command groups having children (required)
|
||||
|
||||
@ -1002,7 +1002,7 @@ class CommandTree(Generic[ClientT]):
|
||||
"""
|
||||
|
||||
if translator is not None and not isinstance(translator, Translator):
|
||||
raise TypeError(f'expected None or Translator instance, received {translator.__class__!r} instead')
|
||||
raise TypeError(f'expected None or Translator instance, received {translator.__class__.__name__} instead')
|
||||
|
||||
old_translator = self._state._translator
|
||||
if old_translator is not None:
|
||||
|
Reference in New Issue
Block a user