Skip to content
This repository was archived by the owner on Aug 28, 2019. It is now read-only.

Commit 1c03a4a

Browse files
committed
Evict keys when they're set to None in PermissionOverwrite
Fixes Rapptz#5929
1 parent b9e1bdf commit 1c03a4a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

discord/permissions.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,10 @@ def _set(self, key, value):
484484
if value not in (True, None, False):
485485
raise TypeError('Expected bool or NoneType, received {0.__class__.__name__}'.format(value))
486486

487-
self._values[key] = value
487+
if value is None:
488+
self._values.pop(key, None)
489+
else:
490+
self._values[key] = value
488491

489492
def pair(self):
490493
"""Tuple[:class:`Permissions`, :class:`Permissions`]: Returns the (allow, deny) pair from this overwrite."""
@@ -519,13 +522,13 @@ def is_empty(self):
519522
520523
An empty permission overwrite is one that has no overwrites set
521524
to ``True`` or ``False``.
522-
525+
523526
Returns
524527
-------
525528
:class:`bool`
526529
Indicates if the overwrite is empty.
527530
"""
528-
return all(x is None for x in self._values.values())
531+
return len(self._values) == 0
529532

530533
def update(self, **kwargs):
531534
r"""Bulk updates this permission overwrite object.

0 commit comments

Comments
 (0)