mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-21 00:07:51 +00:00
Slightly improve performance of constructing Permissions using kwargs
This commit is contained in:
parent
f3b26e795f
commit
b6794fa6d1
@ -141,9 +141,12 @@ class Permissions(BaseFlags):
|
||||
|
||||
self.value = permissions
|
||||
for key, value in kwargs.items():
|
||||
if key not in self.VALID_FLAGS:
|
||||
raise TypeError(f'{key!r} is not a valid permission name.')
|
||||
setattr(self, key, value)
|
||||
try:
|
||||
flag = self.VALID_FLAGS[key]
|
||||
except KeyError:
|
||||
raise TypeError(f'{key!r} is not a valid permission name.') from None
|
||||
else:
|
||||
self._set_flag(flag, value)
|
||||
|
||||
def is_subset(self, other: Permissions) -> bool:
|
||||
"""Returns ``True`` if self has the same or fewer permissions as other."""
|
||||
@ -360,8 +363,9 @@ class Permissions(BaseFlags):
|
||||
A list of key/value pairs to bulk update permissions with.
|
||||
"""
|
||||
for key, value in kwargs.items():
|
||||
if key in self.VALID_FLAGS:
|
||||
setattr(self, key, value)
|
||||
flag = self.VALID_FLAGS.get(key)
|
||||
if flag is not None:
|
||||
self._set_flag(flag, value)
|
||||
|
||||
def handle_overwrite(self, allow: int, deny: int) -> None:
|
||||
# Basically this is what's happening here.
|
||||
|
Loading…
x
Reference in New Issue
Block a user