Fix code style issues with Black
This commit is contained in:
@ -28,8 +28,8 @@ from typing import Callable, Any, ClassVar, Dict, Iterator, Set, TYPE_CHECKING,
|
||||
from .flags import BaseFlags, flag_value, fill_with_flags, alias_flag_value
|
||||
|
||||
__all__ = (
|
||||
'Permissions',
|
||||
'PermissionOverwrite',
|
||||
"Permissions",
|
||||
"PermissionOverwrite",
|
||||
)
|
||||
|
||||
# A permission alias works like a regular flag but is marked
|
||||
@ -46,7 +46,9 @@ def make_permission_alias(alias: str) -> Callable[[Callable[[Any], int]], permis
|
||||
|
||||
return decorator
|
||||
|
||||
P = TypeVar('P', bound='Permissions')
|
||||
|
||||
P = TypeVar("P", bound="Permissions")
|
||||
|
||||
|
||||
@fill_with_flags()
|
||||
class Permissions(BaseFlags):
|
||||
@ -101,12 +103,12 @@ class Permissions(BaseFlags):
|
||||
|
||||
def __init__(self, permissions: int = 0, **kwargs: bool):
|
||||
if not isinstance(permissions, int):
|
||||
raise TypeError(f'Expected int parameter, received {permissions.__class__.__name__} instead.')
|
||||
raise TypeError(f"Expected int parameter, received {permissions.__class__.__name__} instead.")
|
||||
|
||||
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.')
|
||||
raise TypeError(f"{key!r} is not a valid permission name.")
|
||||
setattr(self, key, value)
|
||||
|
||||
def is_subset(self, other: Permissions) -> bool:
|
||||
@ -299,7 +301,7 @@ class Permissions(BaseFlags):
|
||||
"""
|
||||
return 1 << 3
|
||||
|
||||
@make_permission_alias('administrator')
|
||||
@make_permission_alias("administrator")
|
||||
def admin(self) -> int:
|
||||
""":class:`bool`: An alias for :attr:`administrator`.
|
||||
.. versionadded:: 2.0
|
||||
@ -343,7 +345,7 @@ class Permissions(BaseFlags):
|
||||
""":class:`bool`: Returns ``True`` if a user can read messages from all or specific text channels."""
|
||||
return 1 << 10
|
||||
|
||||
@make_permission_alias('read_messages')
|
||||
@make_permission_alias("read_messages")
|
||||
def view_channel(self) -> int:
|
||||
""":class:`bool`: An alias for :attr:`read_messages`.
|
||||
|
||||
@ -396,7 +398,7 @@ class Permissions(BaseFlags):
|
||||
""":class:`bool`: Returns ``True`` if a user can use emojis from other guilds."""
|
||||
return 1 << 18
|
||||
|
||||
@make_permission_alias('external_emojis')
|
||||
@make_permission_alias("external_emojis")
|
||||
def use_external_emojis(self) -> int:
|
||||
""":class:`bool`: An alias for :attr:`external_emojis`.
|
||||
|
||||
@ -460,7 +462,7 @@ class Permissions(BaseFlags):
|
||||
"""
|
||||
return 1 << 28
|
||||
|
||||
@make_permission_alias('manage_roles')
|
||||
@make_permission_alias("manage_roles")
|
||||
def manage_permissions(self) -> int:
|
||||
""":class:`bool`: An alias for :attr:`manage_roles`.
|
||||
|
||||
@ -478,7 +480,7 @@ class Permissions(BaseFlags):
|
||||
""":class:`bool`: Returns ``True`` if a user can create, edit, or delete emojis."""
|
||||
return 1 << 30
|
||||
|
||||
@make_permission_alias('manage_emojis')
|
||||
@make_permission_alias("manage_emojis")
|
||||
def manage_emojis_and_stickers(self) -> int:
|
||||
""":class:`bool`: An alias for :attr:`manage_emojis`.
|
||||
|
||||
@ -542,7 +544,7 @@ class Permissions(BaseFlags):
|
||||
"""
|
||||
return 1 << 37
|
||||
|
||||
@make_permission_alias('external_stickers')
|
||||
@make_permission_alias("external_stickers")
|
||||
def use_external_stickers(self) -> int:
|
||||
""":class:`bool`: An alias for :attr:`external_stickers`.
|
||||
|
||||
@ -558,7 +560,9 @@ class Permissions(BaseFlags):
|
||||
"""
|
||||
return 1 << 38
|
||||
|
||||
PO = TypeVar('PO', bound='PermissionOverwrite')
|
||||
|
||||
PO = TypeVar("PO", bound="PermissionOverwrite")
|
||||
|
||||
|
||||
def _augment_from_permissions(cls):
|
||||
cls.VALID_NAMES = set(Permissions.VALID_FLAGS)
|
||||
@ -621,7 +625,7 @@ class PermissionOverwrite:
|
||||
Set the value of permissions by their name.
|
||||
"""
|
||||
|
||||
__slots__ = ('_values',)
|
||||
__slots__ = ("_values",)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
VALID_NAMES: ClassVar[Set[str]]
|
||||
@ -677,7 +681,7 @@ class PermissionOverwrite:
|
||||
|
||||
for key, value in kwargs.items():
|
||||
if key not in self.VALID_NAMES:
|
||||
raise ValueError(f'no permission called {key}.')
|
||||
raise ValueError(f"no permission called {key}.")
|
||||
|
||||
setattr(self, key, value)
|
||||
|
||||
@ -686,7 +690,7 @@ class PermissionOverwrite:
|
||||
|
||||
def _set(self, key: str, value: Optional[bool]) -> None:
|
||||
if value not in (True, None, False):
|
||||
raise TypeError(f'Expected bool or NoneType, received {value.__class__.__name__}')
|
||||
raise TypeError(f"Expected bool or NoneType, received {value.__class__.__name__}")
|
||||
|
||||
if value is None:
|
||||
self._values.pop(key, None)
|
||||
|
Reference in New Issue
Block a user