mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-01 15:50:02 +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
|
self.value = permissions
|
||||||
for key, value in kwargs.items():
|
for key, value in kwargs.items():
|
||||||
if key not in self.VALID_FLAGS:
|
try:
|
||||||
raise TypeError(f'{key!r} is not a valid permission name.')
|
flag = self.VALID_FLAGS[key]
|
||||||
setattr(self, key, value)
|
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:
|
def is_subset(self, other: Permissions) -> bool:
|
||||||
"""Returns ``True`` if self has the same or fewer permissions as other."""
|
"""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.
|
A list of key/value pairs to bulk update permissions with.
|
||||||
"""
|
"""
|
||||||
for key, value in kwargs.items():
|
for key, value in kwargs.items():
|
||||||
if key in self.VALID_FLAGS:
|
flag = self.VALID_FLAGS.get(key)
|
||||||
setattr(self, key, value)
|
if flag is not None:
|
||||||
|
self._set_flag(flag, value)
|
||||||
|
|
||||||
def handle_overwrite(self, allow: int, deny: int) -> None:
|
def handle_overwrite(self, allow: int, deny: int) -> None:
|
||||||
# Basically this is what's happening here.
|
# Basically this is what's happening here.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user