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/flags.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/flags.py')
| -rw-r--r-- | discord/flags.py | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/discord/flags.py b/discord/flags.py index 9681be8a..d7ceb907 100644 --- a/discord/flags.py +++ b/discord/flags.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - """ The MIT License (MIT) @@ -48,7 +46,7 @@ class flag_value: instance._set_flag(self.flag, value) def __repr__(self): - return '<flag_value flag={.flag!r}>'.format(self) + return f'<flag_value flag={self.flag!r}>' class alias_flag_value(flag_value): pass @@ -78,7 +76,7 @@ class BaseFlags: self.value = self.DEFAULT_VALUE for key, value in kwargs.items(): if key not in self.VALID_FLAGS: - raise TypeError('%r is not a valid flag name.' % key) + raise TypeError(f'{key!r} is not a valid flag name.') setattr(self, key, value) @classmethod @@ -97,7 +95,7 @@ class BaseFlags: return hash(self.value) def __repr__(self): - return '<%s value=%s>' % (self.__class__.__name__, self.value) + return f'<{self.__class__.__name__} value={self.value}>' def __iter__(self): for name, value in self.__class__.__dict__.items(): @@ -116,7 +114,7 @@ class BaseFlags: elif toggle is False: self.value &= ~o else: - raise TypeError('Value to set for %s must be a bool.' % self.__class__.__name__) + raise TypeError(f'Value to set for {self.__class__.__name__} must be a bool.') @fill_with_flags(inverted=True) class SystemChannelFlags(BaseFlags): @@ -399,7 +397,7 @@ class Intents(BaseFlags): self.value = self.DEFAULT_VALUE for key, value in kwargs.items(): if key not in self.VALID_FLAGS: - raise TypeError('%r is not a valid flag name.' % key) + raise TypeError(f'{key!r} is not a valid flag name.') setattr(self, key, value) @classmethod @@ -832,7 +830,7 @@ class MemberCacheFlags(BaseFlags): self.value = (1 << bits) - 1 for key, value in kwargs.items(): if key not in self.VALID_FLAGS: - raise TypeError('%r is not a valid flag name.' % key) + raise TypeError(f'{key!r} is not a valid flag name.') setattr(self, key, value) @classmethod |