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`.
This commit is contained in:
Rapptz
2021-04-04 04:40:19 -04:00
parent 9fc2ab9c99
commit 9d39b135f4
67 changed files with 262 additions and 378 deletions

View File

@@ -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)