Fix code style issues with Black

This commit is contained in:
Lint Action
2021-09-05 21:34:20 +00:00
parent a23dae8604
commit 7513c2138f
108 changed files with 5369 additions and 4858 deletions

View File

@@ -32,8 +32,8 @@ from .mixins import Hashable
from .utils import snowflake_time, _get_as_snowflake, MISSING
__all__ = (
'RoleTags',
'Role',
"RoleTags",
"Role",
)
if TYPE_CHECKING:
@@ -68,19 +68,19 @@ class RoleTags:
"""
__slots__ = (
'bot_id',
'integration_id',
'_premium_subscriber',
"bot_id",
"integration_id",
"_premium_subscriber",
)
def __init__(self, data: RoleTagPayload):
self.bot_id: Optional[int] = _get_as_snowflake(data, 'bot_id')
self.integration_id: Optional[int] = _get_as_snowflake(data, 'integration_id')
self.bot_id: Optional[int] = _get_as_snowflake(data, "bot_id")
self.integration_id: Optional[int] = _get_as_snowflake(data, "integration_id")
# NOTE: The API returns "null" for this if it's valid, which corresponds to None.
# This is different from other fields where "null" means "not there".
# So in this case, a value of None is the same as True.
# Which means we would need a different sentinel.
self._premium_subscriber: Optional[Any] = data.get('premium_subscriber', MISSING)
self._premium_subscriber: Optional[Any] = data.get("premium_subscriber", MISSING)
def is_bot_managed(self) -> bool:
""":class:`bool`: Whether the role is associated with a bot."""
@@ -96,12 +96,12 @@ class RoleTags:
def __repr__(self) -> str:
return (
f'<RoleTags bot_id={self.bot_id} integration_id={self.integration_id} '
f'premium_subscriber={self.is_premium_subscriber()}>'
f"<RoleTags bot_id={self.bot_id} integration_id={self.integration_id} "
f"premium_subscriber={self.is_premium_subscriber()}>"
)
R = TypeVar('R', bound='Role')
R = TypeVar("R", bound="Role")
class Role(Hashable):
@@ -181,23 +181,23 @@ class Role(Hashable):
"""
__slots__ = (
'id',
'name',
'_permissions',
'_colour',
'position',
'managed',
'mentionable',
'hoist',
'guild',
'tags',
'_state',
"id",
"name",
"_permissions",
"_colour",
"position",
"managed",
"mentionable",
"hoist",
"guild",
"tags",
"_state",
)
def __init__(self, *, guild: Guild, state: ConnectionState, data: RolePayload):
self.guild: Guild = guild
self._state: ConnectionState = state
self.id: int = int(data['id'])
self.id: int = int(data["id"])
self._update(data)
def __str__(self) -> str:
@@ -207,14 +207,14 @@ class Role(Hashable):
return self.id
def __repr__(self) -> str:
return f'<Role id={self.id} name={self.name!r}>'
return f"<Role id={self.id} name={self.name!r}>"
def __lt__(self: R, other: R) -> bool:
if not isinstance(other, Role) or not isinstance(self, Role):
return NotImplemented
if self.guild != other.guild:
raise RuntimeError('cannot compare roles from two different guilds.')
raise RuntimeError("cannot compare roles from two different guilds.")
# the @everyone role is always the lowest role in hierarchy
guild_id = self.guild.id
@@ -246,17 +246,17 @@ class Role(Hashable):
return not r
def _update(self, data: RolePayload):
self.name: str = data['name']
self._permissions: int = int(data.get('permissions', 0))
self.position: int = data.get('position', 0)
self._colour: int = data.get('color', 0)
self.hoist: bool = data.get('hoist', False)
self.managed: bool = data.get('managed', False)
self.mentionable: bool = data.get('mentionable', False)
self.name: str = data["name"]
self._permissions: int = int(data.get("permissions", 0))
self.position: int = data.get("position", 0)
self._colour: int = data.get("color", 0)
self.hoist: bool = data.get("hoist", False)
self.managed: bool = data.get("managed", False)
self.mentionable: bool = data.get("mentionable", False)
self.tags: Optional[RoleTags]
try:
self.tags = RoleTags(data['tags'])
self.tags = RoleTags(data["tags"])
except KeyError:
self.tags = None
@@ -316,7 +316,7 @@ class Role(Hashable):
@property
def mention(self) -> str:
""":class:`str`: Returns a string that allows you to mention a role."""
return f'<@&{self.id}>'
return f"<@&{self.id}>"
@property
def members(self) -> List[Member]:
@@ -420,21 +420,21 @@ class Role(Hashable):
if colour is not MISSING:
if isinstance(colour, int):
payload['color'] = colour
payload["color"] = colour
else:
payload['color'] = colour.value
payload["color"] = colour.value
if name is not MISSING:
payload['name'] = name
payload["name"] = name
if permissions is not MISSING:
payload['permissions'] = permissions.value
payload["permissions"] = permissions.value
if hoist is not MISSING:
payload['hoist'] = hoist
payload["hoist"] = hoist
if mentionable is not MISSING:
payload['mentionable'] = mentionable
payload["mentionable"] = mentionable
data = await self._state.http.edit_role(self.guild.id, self.id, reason=reason, **payload)
return Role(guild=self.guild, data=data, state=self._state)