diff --git a/discord/__main__.py b/discord/__main__.py index 31c61553..91a3000f 100644 --- a/discord/__main__.py +++ b/discord/__main__.py @@ -35,14 +35,16 @@ def show_version(): - entries = [] + entries = [ + '- Python v{0.major}.{0.minor}.{0.micro}-{0.releaselevel}'.format( + sys.version_info + ) + ] - entries.append('- Python v{0.major}.{0.minor}.{0.micro}-{0.releaselevel}'.format(sys.version_info)) version_info = discord.version_info entries.append('- discord.py v{0.major}.{0.minor}.{0.micro}-{0.releaselevel}'.format(version_info)) if version_info.releaselevel != 'final': - pkg = pkg_resources.get_distribution('discord.py') - if pkg: + if pkg := pkg_resources.get_distribution('discord.py'): entries.append(' - discord.py pkg_resources: v{0}'.format(pkg.version)) entries.append('- aiohttp v{0.__version__}'.format(aiohttp)) @@ -176,7 +178,7 @@ async def cog_after_invoke(self, ctx): } # NUL (0) and 1-31 are disallowed -_base_table.update((chr(i), None) for i in range(32)) +_base_table |= ((chr(i), None) for i in range(32)) translation_table = str.maketrans(_base_table) @@ -205,7 +207,7 @@ def newbot(parser, args): try: new_directory.mkdir(exist_ok=True, parents=True) except OSError as exc: - parser.error('could not create our bot directory ({})'.format(exc)) + parser.error(f'could not create our bot directory ({exc})') cogs = new_directory / 'cogs' @@ -214,27 +216,27 @@ def newbot(parser, args): init = cogs / '__init__.py' init.touch() except OSError as exc: - print('warning: could not create cogs directory ({})'.format(exc)) + print(f'warning: could not create cogs directory ({exc})') try: with open(str(new_directory / 'config.py'), 'w', encoding='utf-8') as fp: fp.write('token = "place your token here"\ncogs = []\n') except OSError as exc: - parser.error('could not create config file ({})'.format(exc)) + parser.error(f'could not create config file ({exc})') try: with open(str(new_directory / 'bot.py'), 'w', encoding='utf-8') as fp: base = 'Bot' if not args.sharded else 'AutoShardedBot' fp.write(bot_template.format(base=base, prefix=args.prefix)) except OSError as exc: - parser.error('could not create bot file ({})'.format(exc)) + parser.error(f'could not create bot file ({exc})') if not args.no_git: try: with open(str(new_directory / '.gitignore'), 'w', encoding='utf-8') as fp: fp.write(gitignore_template) except OSError as exc: - print('warning: could not create .gitignore file ({})'.format(exc)) + print(f'warning: could not create .gitignore file ({exc})') print('successfully made bot at', new_directory) @@ -244,7 +246,7 @@ def newcog(parser, args): try: cog_dir.mkdir(exist_ok=True) except OSError as exc: - print('warning: could not create cogs directory ({})'.format(exc)) + print(f'warning: could not create cogs directory ({exc})') directory = cog_dir / to_path(parser, args.name) directory = directory.with_suffix('.py') @@ -263,12 +265,12 @@ def newcog(parser, args): name = name.title() if args.display_name: - attrs += ', name="{}"'.format(args.display_name) + attrs += f', name="{args.display_name}"' if args.hide_commands: attrs += ', command_attrs=dict(hidden=True)' fp.write(cog_template.format(name=name, extra=extra, attrs=attrs)) except OSError as exc: - parser.error('could not create cog file ({})'.format(exc)) + parser.error(f'could not create cog file ({exc})') else: print('successfully made cog at', directory) diff --git a/discord/abc.py b/discord/abc.py index a202f28c..c2b6dfd7 100644 --- a/discord/abc.py +++ b/discord/abc.py @@ -124,19 +124,19 @@ def mention(self): @classmethod def __subclasshook__(cls, C): - if cls is User: - if Snowflake.__subclasshook__(C) is NotImplemented: - return NotImplemented + if cls is not User: + return NotImplemented + if Snowflake.__subclasshook__(C) is NotImplemented: + return NotImplemented - mro = C.__mro__ - for attr in ('display_name', 'mention', 'name', 'avatar', 'discriminator', 'bot'): - for base in mro: - if attr in base.__dict__: - break - else: - return NotImplemented - return True - return NotImplemented + mro = C.__mro__ + for attr in ('display_name', 'mention', 'name', 'avatar', 'discriminator', 'bot'): + for base in mro: + if attr in base.__dict__: + break + else: + return NotImplemented + return True class PrivateChannel(metaclass=abc.ABCMeta): """An ABC that details the common operations on a private Discord channel. @@ -162,10 +162,7 @@ def __subclasshook__(cls, C): return NotImplemented mro = C.__mro__ - for base in mro: - if 'me' in base.__dict__: - return True - return NotImplemented + return next((True for base in mro if 'me' in base.__dict__), NotImplemented) return NotImplemented class _Overwrites: @@ -298,14 +295,10 @@ async def _edit(self, options, reason): payload = { 'allow': allow.value, 'deny': deny.value, - 'id': target.id + 'id': target.id, + 'type': 'role' if isinstance(target, Role) else 'member', } - if isinstance(target, Role): - payload['type'] = 'role' - else: - payload['type'] = 'member' - perms.append(payload) options['permission_overwrites'] = perms @@ -330,7 +323,9 @@ def _fill_overwrites(self, data): for index, overridden in enumerate(data.get('permission_overwrites', [])): overridden_type = try_enum(PermissionType, overridden.pop('type')) if not overridden_type: - raise AttributeError('Type type should be 0 - member, or 1 - role not %s' % overridden_type) + raise AttributeError( + f'Type type should be 0 - member, or 1 - role not {overridden_type}' + ) overridden_id = int(overridden.pop('id')) self._overwrites.append(_Overwrites(id=overridden_id, type=overridden_type.name, **overridden)) @@ -345,9 +340,7 @@ def _fill_overwrites(self, data): # swap it to be the first one. everyone_index = index - # do the swap - tmp = self._overwrites - if tmp: + if tmp := self._overwrites: tmp[everyone_index], tmp[0] = tmp[0], tmp[everyone_index] @property @@ -369,7 +362,7 @@ def changed_roles(self): @property def mention(self): """:class:`str`: The string that allows you to mention the channel.""" - return '<#%s>' % self.id + return f'<#{self.id}>' @property def created_at(self): @@ -654,15 +647,14 @@ async def set_permissions(self, target, *, overwrite=_undefined, reason=None, ** raise InvalidArgument('target parameter must be either Member or Role') if isinstance(overwrite, _Undefined): - if len(permissions) == 0: + if not permissions: raise InvalidArgument('No overwrite provided.') try: overwrite = PermissionOverwrite(**permissions) except (ValueError, TypeError): raise InvalidArgument('Invalid permissions given to keyword arguments.') - else: - if len(permissions) > 0: - raise InvalidArgument('Cannot mix overwrite and keyword arguments.') + elif permissions: + raise InvalidArgument('Cannot mix overwrite and keyword arguments.') # TODO: wait for event @@ -1049,14 +1041,13 @@ async def send(self, content=None, *, tts=False, embed=None, embeds=None, compon _components.extend(ActionRow(*[obj for obj in component if isinstance(obj, (Button, SelectMenu))]).to_dict()) components = _components - if allowed_mentions is not None: - if state.allowed_mentions is not None: - allowed_mentions = state.allowed_mentions.merge(allowed_mentions).to_dict() - else: - allowed_mentions = allowed_mentions.to_dict() - else: + if allowed_mentions is None: allowed_mentions = state.allowed_mentions and state.allowed_mentions.to_dict() + elif state.allowed_mentions is not None: + allowed_mentions = state.allowed_mentions.merge(allowed_mentions).to_dict() + else: + allowed_mentions = allowed_mentions.to_dict() if mention_author is not None: allowed_mentions = allowed_mentions or AllowedMentions().to_dict() allowed_mentions['replied_user'] = bool(mention_author) @@ -1085,22 +1076,37 @@ async def send(self, content=None, *, tts=False, embed=None, embeds=None, compon raise InvalidArgument('file parameter must be File') try: - if hidden is not None: - data = await state.http.send_interaction_response(use_webhook=use_webhook, - interaction_id=interaction_id, - token=interaction_token, - application_id=application_id, - deferred=deferred, - files=[file], allowed_mentions=allowed_mentions, - content=content, tts=tts, embeds=embeds, - components=components, - nonce=nonce, message_reference=reference, - flags=64 if hidden is True else None, - followup=followup) - else: - data = await state.http.send_files(channel.id, files=[file], allowed_mentions=allowed_mentions, - content=content, tts=tts, embeds=embeds, components=components, - nonce=nonce, message_reference=reference) + data = ( + await state.http.send_interaction_response( + use_webhook=use_webhook, + interaction_id=interaction_id, + token=interaction_token, + application_id=application_id, + deferred=deferred, + files=[file], + allowed_mentions=allowed_mentions, + content=content, + tts=tts, + embeds=embeds, + components=components, + nonce=nonce, + message_reference=reference, + flags=64 if hidden is True else None, + followup=followup, + ) + if hidden is not None + else await state.http.send_files( + channel.id, + files=[file], + allowed_mentions=allowed_mentions, + content=content, + tts=tts, + embeds=embeds, + components=components, + nonce=nonce, + message_reference=reference, + ) + ) finally: file.close() @@ -1130,28 +1136,27 @@ async def send(self, content=None, *, tts=False, embed=None, embeds=None, compon finally: for f in files: f.close() + elif hidden is not None: + data = await state.http.send_interaction_response(use_webhook=use_webhook, + interaction_id=interaction_id, + token=interaction_token, + application_id=application_id, + deferred=deferred, allowed_mentions=allowed_mentions, + content=content, tts=tts, embeds=embeds, + components=components, + nonce=nonce, message_reference=reference, + flags=64 if hidden is True else None, + followup=followup) else: - if hidden is not None: - data = await state.http.send_interaction_response(use_webhook=use_webhook, - interaction_id=interaction_id, - token=interaction_token, - application_id=application_id, - deferred=deferred, allowed_mentions=allowed_mentions, - content=content, tts=tts, embeds=embeds, - components=components, - nonce=nonce, message_reference=reference, - flags=64 if hidden is True else None, - followup=followup) - else: - data = await state.http.send_message(channel.id, content, tts=tts, embeds=embeds, components=components, - nonce=nonce, allowed_mentions=allowed_mentions, - message_reference=reference) - if not hidden is True: - if not isinstance(data, dict) and not hidden is None: + data = await state.http.send_message(channel.id, content, tts=tts, embeds=embeds, components=components, + nonce=nonce, allowed_mentions=allowed_mentions, + message_reference=reference) + if hidden is not True: + if not isinstance(data, dict) and hidden is not None: """Thanks Discord that they dont return the message when we send the interaction callback""" data = await state.http.get_original_interaction_response(application_id=application_id, interaction_token=interaction_token) ret = state.create_message(channel=channel, data=data) - if (delete_after is not None) and (not hidden is True): + if delete_after is not None and hidden is not True: await ret.delete(delay=delete_after) return ret diff --git a/discord/activity.py b/discord/activity.py index cf5192ad..76b93c95 100644 --- a/discord/activity.py +++ b/discord/activity.py @@ -189,10 +189,7 @@ def __init__(self, **kwargs): self.session_id = kwargs.pop('session_id', None) self.type = try_enum(ActivityType, kwargs.pop('type', -1)) emoji = kwargs.pop('emoji', None) - if emoji is not None: - self.emoji = PartialEmoji.from_dict(emoji) - else: - self.emoji = None + self.emoji = PartialEmoji.from_dict(emoji) if emoji is not None else None def __repr__(self): attrs = ( @@ -205,7 +202,7 @@ def __repr__(self): 'emoji', ) mapped = ' '.join('%s=%r' % (attr, getattr(self, attr)) for attr in attrs) - return '' % mapped + return f'' def to_dict(self): ret = {} @@ -332,9 +329,9 @@ def _extract_timestamp(self, data, key): try: dt = data[key] except KeyError: - setattr(self, '_' + key, 0) + setattr(self, f'_{key}', 0) else: - setattr(self, '_' + key, dt.timestamp() * 1000.0) + setattr(self, f'_{key}', dt.timestamp() * 1000.0) @property def type(self): @@ -624,7 +621,7 @@ def album_cover_url(self): if large_image[:8] != 'spotify:': return '' album_image_id = large_image[8:] - return 'https://i.scdn.co/image/' + album_image_id + return f'https://i.scdn.co/image/{album_image_id}' @property def track_id(self): @@ -737,12 +734,9 @@ def __hash__(self): return hash((self.name, str(self.emoji))) def __str__(self): - if self.emoji: - if self.name: - return '%s %s' % (self.emoji, self.name) - return str(self.emoji) - else: + if not self.emoji: return str(self.name) + return f'{self.emoji} {self.name}' if self.name else str(self.emoji) def __repr__(self): return ''.format(self) @@ -765,9 +759,7 @@ def create_activity(data): else: return CustomActivity(name=name, **data) elif game_type is ActivityType.streaming: - if 'url' in data: - return Streaming(**data) - return Activity(**data) + return Streaming(**data) if 'url' in data else Activity(**data) elif game_type is ActivityType.listening and 'sync_id' in data and 'session_id' in data: return Spotify(**data) return Activity(**data) diff --git a/discord/asset.py b/discord/asset.py index ea457297..04c73200 100644 --- a/discord/asset.py +++ b/discord/asset.py @@ -74,11 +74,11 @@ def _from_avatar(cls, state, user, *, format=None, static_format='webp', size=10 if not utils.valid_icon_size(size): raise InvalidArgument("size must be a power of 2 between 16 and 4096") if format is not None and format not in VALID_AVATAR_FORMATS: - raise InvalidArgument("format must be None or one of {}".format(VALID_AVATAR_FORMATS)) + raise InvalidArgument(f"format must be None or one of {VALID_AVATAR_FORMATS}") if format == "gif" and not user.is_avatar_animated(): raise InvalidArgument("non animated avatars do not support gif format") if static_format not in VALID_STATIC_FORMATS: - raise InvalidArgument("static_format must be one of {}".format(VALID_STATIC_FORMATS)) + raise InvalidArgument(f"static_format must be one of {VALID_STATIC_FORMATS}") if user.avatar is None: return user.default_avatar_url @@ -96,7 +96,7 @@ def _from_icon(cls, state, object, path, *, format='webp', size=1024): if not utils.valid_icon_size(size): raise InvalidArgument("size must be a power of 2 between 16 and 4096") if format not in VALID_STATIC_FORMATS: - raise InvalidArgument("format must be None or one of {}".format(VALID_STATIC_FORMATS)) + raise InvalidArgument(f"format must be None or one of {VALID_STATIC_FORMATS}") url = '/{0}-icons/{1.id}/{1.icon}.{2}?size={3}'.format(path, object, format, size) return cls(state, url) @@ -109,7 +109,7 @@ def _from_cover_image(cls, state, obj, *, format='webp', size=1024): if not utils.valid_icon_size(size): raise InvalidArgument("size must be a power of 2 between 16 and 4096") if format not in VALID_STATIC_FORMATS: - raise InvalidArgument("format must be None or one of {}".format(VALID_STATIC_FORMATS)) + raise InvalidArgument(f"format must be None or one of {VALID_STATIC_FORMATS}") url = '/app-assets/{0.id}/store/{0.cover_image}.{1}?size={2}'.format(obj, format, size) return cls(state, url) @@ -119,7 +119,7 @@ def _from_guild_image(cls, state, id, hash, key, *, format='webp', size=1024): if not utils.valid_icon_size(size): raise InvalidArgument("size must be a power of 2 between 16 and 4096") if format not in VALID_STATIC_FORMATS: - raise InvalidArgument("format must be one of {}".format(VALID_STATIC_FORMATS)) + raise InvalidArgument(f"format must be one of {VALID_STATIC_FORMATS}") if hash is None: return cls(state) @@ -132,11 +132,11 @@ def _from_guild_icon(cls, state, guild, *, format=None, static_format='webp', si if not utils.valid_icon_size(size): raise InvalidArgument("size must be a power of 2 between 16 and 4096") if format is not None and format not in VALID_AVATAR_FORMATS: - raise InvalidArgument("format must be one of {}".format(VALID_AVATAR_FORMATS)) + raise InvalidArgument(f"format must be one of {VALID_AVATAR_FORMATS}") if format == "gif" and not guild.is_icon_animated(): raise InvalidArgument("non animated guild icons do not support gif format") if static_format not in VALID_STATIC_FORMATS: - raise InvalidArgument("static_format must be one of {}".format(VALID_STATIC_FORMATS)) + raise InvalidArgument(f"static_format must be one of {VALID_STATIC_FORMATS}") if guild.icon is None: return cls(state) @@ -156,11 +156,11 @@ def _from_sticker_url(cls, state, sticker, *, size=1024): @classmethod def _from_emoji(cls, state, emoji, *, format=None, static_format='png'): if format is not None and format not in VALID_AVATAR_FORMATS: - raise InvalidArgument("format must be None or one of {}".format(VALID_AVATAR_FORMATS)) + raise InvalidArgument(f"format must be None or one of {VALID_AVATAR_FORMATS}") if format == "gif" and not emoji.animated: raise InvalidArgument("non animated emoji's do not support gif format") if static_format not in VALID_STATIC_FORMATS: - raise InvalidArgument("static_format must be one of {}".format(VALID_STATIC_FORMATS)) + raise InvalidArgument(f"static_format must be one of {VALID_STATIC_FORMATS}") if format is None: format = 'gif' if emoji.animated else static_format @@ -170,9 +170,7 @@ def __str__(self): return self.BASE + self._url if self._url is not None else '' def __len__(self): - if self._url: - return len(self.BASE + self._url) - return 0 + return len(self.BASE + self._url) if self._url else 0 def __bool__(self): return self._url is not None diff --git a/discord/audit_logs.py b/discord/audit_logs.py index 00706f89..63f0f1f2 100644 --- a/discord/audit_logs.py +++ b/discord/audit_logs.py @@ -55,14 +55,10 @@ def _transform_channel(entry, data): return entry.guild.get_channel(int(data)) or Object(id=data) def _transform_owner_id(entry, data): - if data is None: - return None - return entry._get_member(int(data)) + return None if data is None else entry._get_member(int(data)) def _transform_inviter_id(entry, data): - if data is None: - return None - return entry._get_member(int(data)) + return None if data is None else entry._get_member(int(data)) def _transform_overwrites(entry, data): overwrites = [] @@ -94,7 +90,7 @@ def __iter__(self): def __repr__(self): values = ' '.join('%s=%r' % item for item in self.__dict__.items()) - return '' % values + return f'' class AuditLogChanges: TRANSFORMERS = { @@ -307,7 +303,7 @@ def created_at(self): @utils.cached_property def target(self): try: - converter = getattr(self, '_convert_target_' + self.action.target_type) + converter = getattr(self, f'_convert_target_{self.action.target_type}') except AttributeError: return Object(id=self._target_id) else: @@ -340,18 +336,14 @@ def _convert_target_guild(self, target_id): def _convert_target_channel(self, target_id): ch = self.guild.get_channel(target_id) - if ch is None: - return Object(id=target_id) - return ch + return Object(id=target_id) if ch is None else ch def _convert_target_user(self, target_id): return self._get_member(target_id) def _convert_target_role(self, target_id): role = self.guild.get_role(target_id) - if role is None: - return Object(id=target_id) - return role + return Object(id=target_id) if role is None else role def _convert_target_invite(self, target_id): # invites have target_id set to null diff --git a/discord/channel.py b/discord/channel.py index 067470bb..5c0560a1 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -135,7 +135,7 @@ def __repr__(self): ('news', self.is_news()), ('category_id', self.category_id) ] - return '<%s %s>' % (self.__class__.__name__, ' '.join('%s=%r' % t for t in attrs)) + return f"<{self.__class__.__name__} {' '.join('%s=%r' % t for t in attrs)}>" def _update(self, guild, data): self.guild = guild @@ -688,7 +688,7 @@ def __repr__(self): ('user_limit', self.user_limit), ('category_id', self.category_id) ] - return '<%s %s>' % (self.__class__.__name__, ' '.join('%s=%r' % t for t in attrs)) + return f"<{self.__class__.__name__} {' '.join('%s=%r' % t for t in attrs)}>" @property def type(self): @@ -811,7 +811,7 @@ def __repr__(self): ('user_limit', self.user_limit), ('category_id', self.category_id) ] - return '<%s %s>' % (self.__class__.__name__, ' '.join('%s=%r' % t for t in attrs)) + return f"<{self.__class__.__name__} {' '.join('%s=%r' % t for t in attrs)}>" def _update(self, guild, data): super()._update(guild, data) @@ -1239,7 +1239,7 @@ async def _get_channel(self): return self def __str__(self): - return 'Direct Message with %s' % self.recipient + return f'Direct Message with {self.recipient}' def __repr__(self): return ''.format(self) diff --git a/discord/client.py b/discord/client.py index 632a5beb..3c9e9905 100644 --- a/discord/client.py +++ b/discord/client.py @@ -108,7 +108,7 @@ def __repr__(self): ] if self._exception is not None: info.append(('exception', repr(self._exception))) - return ''.format(' '.join('%s=%s' % t for t in info)) + return f"" class Client: r"""Represents a client connection that connects to Discord. @@ -288,9 +288,7 @@ def is_ws_ratelimited(self): .. versionadded:: 1.6 """ - if self.ws: - return self.ws.is_ratelimited() - return False + return self.ws.is_ratelimited() if self.ws else False @property def user(self): @@ -356,10 +354,9 @@ def _schedule_event(self, coro, event_name, *args, **kwargs): def dispatch(self, event, *args, **kwargs): log.debug('Dispatching event %s', event) - method = 'on_' + event + method = f'on_{event}' - listeners = self._listeners.get(event) - if listeners: + if listeners := self._listeners.get(event): removed = [] for i, (future, condition) in enumerate(listeners): if isinstance(future, asyncio.Future): @@ -374,7 +371,7 @@ def dispatch(self, event, *args, **kwargs): removed.append(i) else: if result: - if len(args) == 0: + if not args: future.set_result(None) elif len(args) == 1: future.set_result(args[0]) @@ -387,10 +384,8 @@ def dispatch(self, event, *args, **kwargs): else: for idx in reversed(removed): del listeners[idx] - else: - result = condition(*args) - if result: - self._schedule_event(future, method, *args, **kwargs) + elif result := condition(*args): + self._schedule_event(future, method, *args, **kwargs) try: @@ -409,7 +404,7 @@ async def on_error(self, event_method, *args, **kwargs): overridden to have a different implementation. Check :func:`~discord.on_error` for more details. """ - print('Ignoring exception in {}'.format(event_method), file=sys.stderr) + print(f'Ignoring exception in {event_method}', file=sys.stderr) traceback.print_exc() @utils.deprecated('Guild.chunk') @@ -666,7 +661,7 @@ async def start(self, *args, **kwargs): reconnect = kwargs.pop('reconnect', True) if kwargs: - raise TypeError("unexpected keyword argument(s) %s" % list(kwargs.keys())) + raise TypeError(f"unexpected keyword argument(s) {list(kwargs.keys())}") await self.login(*args, bot=bot) await self.connect(reconnect=reconnect) @@ -865,8 +860,7 @@ def get_all_channels(self): """ for guild in self.guilds: - for channel in guild.channels: - yield channel + yield from guild.channels def get_all_members(self): """Returns a generator with every :class:`.Member` the client can see. @@ -883,8 +877,7 @@ def get_all_members(self): A member the client can see. """ for guild in self.guilds: - for member in guild.members: - yield member + yield from guild.members # listeners/waiters @@ -1183,11 +1176,7 @@ async def change_presence(self, *, activity=None, status=None, afk=False): if me is None: continue - if activity is not None: - me.activities = (activity,) - else: - me.activities = () - + me.activities = (activity, ) if activity is not None else () me.status = status_enum # Guild stuff @@ -1580,13 +1569,10 @@ async def fetch_channel(self, channel_id): raise InvalidData('Unknown channel type {type} for channel ID {id}.'.format_map(data)) if ch_type in (ChannelType.group, ChannelType.private): - channel = factory(me=self.user, data=data, state=self._connection) - else: - guild_id = int(data['guild_id']) - guild = self.get_guild(guild_id) or Object(id=guild_id) - channel = factory(guild=guild, state=self._connection, data=data) - - return channel + return factory(me=self.user, data=data, state=self._connection) + guild_id = int(data['guild_id']) + guild = self.get_guild(guild_id) or Object(id=guild_id) + return factory(guild=guild, state=self._connection, data=data) async def fetch_webhook(self, webhook_id): """|coro| diff --git a/discord/colour.py b/discord/colour.py index fbf9aaef..ef4bc92e 100644 --- a/discord/colour.py +++ b/discord/colour.py @@ -61,7 +61,9 @@ class Colour: def __init__(self, value): if not isinstance(value, int): - raise TypeError('Expected int parameter, received %s instead.' % value.__class__.__name__) + raise TypeError( + f'Expected int parameter, received {value.__class__.__name__} instead.' + ) self.value = value @@ -78,7 +80,7 @@ def __str__(self): return '#{:0>6x}'.format(self.value) def __repr__(self): - return '' % self.value + return f'' def __hash__(self): return hash(self.value) diff --git a/discord/components.py b/discord/components.py index f20e5a78..37f381a0 100644 --- a/discord/components.py +++ b/discord/components.py @@ -105,12 +105,10 @@ def __init__(self, label: str = None, self.disabled = disabled def __repr__(self) -> str: - return f'