mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-10-20 23:42:58 +00:00
Refactor certain f-strings and literals
This commit is contained in:
@@ -431,7 +431,7 @@ class EnumValueTransformer(Transformer):
|
||||
|
||||
values = list(enum)
|
||||
if len(values) < 2:
|
||||
raise TypeError(f'enum.Enum requires at least two values.')
|
||||
raise TypeError('enum.Enum requires at least two values.')
|
||||
|
||||
first = type(values[0].value)
|
||||
if first is int:
|
||||
@@ -469,7 +469,7 @@ class EnumNameTransformer(Transformer):
|
||||
|
||||
values = list(enum)
|
||||
if len(values) < 2:
|
||||
raise TypeError(f'enum.Enum requires at least two values.')
|
||||
raise TypeError('enum.Enum requires at least two values.')
|
||||
|
||||
self._enum: Any = enum
|
||||
self._choices = [Choice(name=v.name, value=v.name) for v in values]
|
||||
@@ -531,7 +531,7 @@ else:
|
||||
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')
|
||||
raise TypeError('Transform only accepts exactly two arguments')
|
||||
|
||||
_, transformer = items
|
||||
|
||||
@@ -635,7 +635,7 @@ class BaseChannelTransformer(Transformer):
|
||||
try:
|
||||
types.extend(CHANNEL_TO_TYPES[t])
|
||||
except KeyError:
|
||||
raise TypeError(f'Union type of channels must be entirely made up of channels') from None
|
||||
raise TypeError('Union type of channels must be entirely made up of channels') from None
|
||||
|
||||
self._types: Tuple[Type[Any]] = channel_types
|
||||
self._channel_types: List[ChannelType] = types
|
||||
@@ -763,7 +763,7 @@ def get_supported_annotation(
|
||||
else:
|
||||
return (EnumNameTransformer(annotation), MISSING, False)
|
||||
if annotation is Choice:
|
||||
raise TypeError(f'Choice requires a type argument of int, str, or float')
|
||||
raise TypeError('Choice requires a type argument of int, str, or float')
|
||||
|
||||
# Check if a transform @classmethod is given to the class
|
||||
# These flatten into simple "inline" transformers with implicit strings
|
||||
@@ -771,9 +771,9 @@ def get_supported_annotation(
|
||||
if isinstance(transform_classmethod, classmethod):
|
||||
params = inspect.signature(transform_classmethod.__func__).parameters
|
||||
if len(params) != 3:
|
||||
raise TypeError(f'Inline transformer with transform classmethod requires 3 parameters')
|
||||
raise TypeError('Inline transformer with transform classmethod requires 3 parameters')
|
||||
if not inspect.iscoroutinefunction(transform_classmethod.__func__):
|
||||
raise TypeError(f'Inline transformer with transform classmethod must be a coroutine')
|
||||
raise TypeError('Inline transformer with transform classmethod must be a coroutine')
|
||||
return (InlineTransformer(annotation), MISSING, False)
|
||||
|
||||
# Check if there's an origin
|
||||
|
Reference in New Issue
Block a user