diff options
| author | Rapptz <[email protected]> | 2021-04-04 04:40:19 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2021-04-04 07:03:53 -0400 |
| commit | 9d39b135f4f84239787b0901d06a4f370a82d4bb (patch) | |
| tree | 8826845cfd47eafa5c9d2ef1fcbedd36382714f4 /discord/channel.py | |
| parent | Bump minimum Python version to 3.8 (diff) | |
| download | discord.py-9d39b135f4f84239787b0901d06a4f370a82d4bb.tar.xz discord.py-9d39b135f4f84239787b0901d06a4f370a82d4bb.zip | |
Modernize code to use f-strings
This also removes the encoding on the top, since Python 3 does it by
default. It also changes some methods to use `yield from`.
Diffstat (limited to 'discord/channel.py')
| -rw-r--r-- | discord/channel.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/discord/channel.py b/discord/channel.py index bd4a39dc..00f77db0 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - """ The MIT License (MIT) @@ -115,7 +113,8 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): ('news', self.is_news()), ('category_id', self.category_id) ] - return '<%s %s>' % (self.__class__.__name__, ' '.join('%s=%r' % t for t in attrs)) + joined = ' '.join('%s=%r' % t for t in attrs) + return f'<{self.__class__.__name__} {joined}>' def _update(self, guild, data): self.guild = guild @@ -668,7 +667,8 @@ class VoiceChannel(VocalGuildChannel): ('user_limit', self.user_limit), ('category_id', self.category_id) ] - return '<%s %s>' % (self.__class__.__name__, ' '.join('%s=%r' % t for t in attrs)) + joined = ' '.join('%s=%r' % t for t in attrs) + return f'<{self.__class__.__name__} {joined}>' @property def type(self): @@ -791,7 +791,8 @@ class StageChannel(VocalGuildChannel): ('user_limit', self.user_limit), ('category_id', self.category_id) ] - return '<%s %s>' % (self.__class__.__name__, ' '.join('%s=%r' % t for t in attrs)) + joined = ' '.join('%s=%r' % t for t in attrs) + return f'<{self.__class__.__name__} {joined}>' def _update(self, guild, data): super()._update(guild, data) @@ -1219,7 +1220,7 @@ class DMChannel(discord.abc.Messageable, Hashable): return self def __str__(self): - return 'Direct Message with %s' % self.recipient + return f'Direct Message with {self.recipient}' def __repr__(self): return '<DMChannel id={0.id} recipient={0.recipient!r}>'.format(self) |