Skip to content

Commit

Permalink
Merge pull request #95 from nekokatt/task/upgrade-black
Browse files Browse the repository at this point in the history
Upgraded and baselined to black v20.8b1, which causes several major reformats.
  • Loading branch information
Nekokatt authored Aug 27, 2020
2 parents 88215a5 + d652816 commit 65e06a0
Show file tree
Hide file tree
Showing 47 changed files with 635 additions and 157 deletions.
9 changes: 7 additions & 2 deletions hikari/api/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,10 @@ def get_invites_view_for_guild(

@abc.abstractmethod
def get_invites_view_for_channel(
self, guild_id: snowflakes.Snowflake, channel_id: snowflakes.Snowflake, /,
self,
guild_id: snowflakes.Snowflake,
channel_id: snowflakes.Snowflake,
/,
) -> CacheView[str, invites.InviteWithMetadata]:
"""Get a view of the invite objects in the cache for a specified channel.
Expand Down Expand Up @@ -1548,7 +1551,9 @@ def clear_voice_states_for_guild(

@abc.abstractmethod
def clear_voice_states_for_channel(
self, guild_id: snowflakes.Snowflake, channel_id: snowflakes.Snowflake,
self,
guild_id: snowflakes.Snowflake,
channel_id: snowflakes.Snowflake,
) -> CacheView[snowflakes.Snowflake, voices.VoiceState]:
"""Remove the voice state objects cached for a specific channel.
Expand Down
5 changes: 4 additions & 1 deletion hikari/api/entity_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,10 @@ def deserialize_member(

@abc.abstractmethod
def deserialize_role(
self, payload: data_binding.JSONObject, *, guild_id: snowflakes.Snowflake,
self,
payload: data_binding.JSONObject,
*,
guild_id: snowflakes.Snowflake,
) -> guild_models.Role:
"""Parse a raw payload from Discord into a role object.
Expand Down
8 changes: 6 additions & 2 deletions hikari/api/event_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,10 @@ async def on_message(event):

@abc.abstractmethod
def get_listeners(
self, event_type: typing.Type[EventT_co], *, polymorphic: bool = True,
self,
event_type: typing.Type[EventT_co],
*,
polymorphic: bool = True,
) -> typing.Collection[CallbackT[EventT_co]]:
"""Get the listeners for a given event type, if there are any.
Expand Down Expand Up @@ -237,7 +240,8 @@ def get_listeners(

@abc.abstractmethod
def listen(
self, event_type: typing.Optional[typing.Type[EventT_co]] = None,
self,
event_type: typing.Optional[typing.Type[EventT_co]] = None,
) -> typing.Callable[[CallbackT[EventT_co]], CallbackT[EventT_co]]:
"""Generate a decorator to subscribe a callback to an event type.
Expand Down
4 changes: 3 additions & 1 deletion hikari/api/event_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,9 @@ def deserialize_message_reaction_remove_emoji_event(
################

def deserialize_ready_event(
self, shard: gateway_shard.GatewayShard, payload: data_binding.JSONObject,
self,
shard: gateway_shard.GatewayShard,
payload: data_binding.JSONObject,
) -> shard_events.ShardReadyEvent:
"""Parse a raw payload from Discord into a ready event object.
Expand Down
31 changes: 22 additions & 9 deletions hikari/api/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1098,13 +1098,15 @@ async def fetch_webhook(

@abc.abstractmethod
async def fetch_channel_webhooks(
self, channel: snowflakes.SnowflakeishOr[channels.TextChannel],
self,
channel: snowflakes.SnowflakeishOr[channels.TextChannel],
) -> typing.Sequence[webhooks.Webhook]:
...

@abc.abstractmethod
async def fetch_guild_webhooks(
self, guild: snowflakes.SnowflakeishOr[guilds.PartialGuild],
self,
guild: snowflakes.SnowflakeishOr[guilds.PartialGuild],
) -> typing.Sequence[webhooks.Webhook]:
...

Expand Down Expand Up @@ -1437,7 +1439,9 @@ async def reposition_channels(

@abc.abstractmethod
async def fetch_member(
self, guild: snowflakes.SnowflakeishOr[guilds.PartialGuild], user: snowflakes.SnowflakeishOr[users.PartialUser],
self,
guild: snowflakes.SnowflakeishOr[guilds.PartialGuild],
user: snowflakes.SnowflakeishOr[users.PartialUser],
) -> guilds.Member:
...

Expand Down Expand Up @@ -1540,18 +1544,24 @@ async def unban_user(

@abc.abstractmethod
async def fetch_ban(
self, guild: snowflakes.SnowflakeishOr[guilds.PartialGuild], user: snowflakes.SnowflakeishOr[users.PartialUser],
self,
guild: snowflakes.SnowflakeishOr[guilds.PartialGuild],
user: snowflakes.SnowflakeishOr[users.PartialUser],
) -> guilds.GuildMemberBan:
...

@abc.abstractmethod
async def fetch_bans(
self, guild: snowflakes.SnowflakeishOr[guilds.PartialGuild],
self,
guild: snowflakes.SnowflakeishOr[guilds.PartialGuild],
) -> typing.Sequence[guilds.GuildMemberBan]:
...

@abc.abstractmethod
async def fetch_roles(self, guild: snowflakes.SnowflakeishOr[guilds.PartialGuild],) -> typing.Sequence[guilds.Role]:
async def fetch_roles(
self,
guild: snowflakes.SnowflakeishOr[guilds.PartialGuild],
) -> typing.Sequence[guilds.Role]:
...

@abc.abstractmethod
Expand Down Expand Up @@ -1699,19 +1709,22 @@ async def begin_guild_prune(

@abc.abstractmethod
async def fetch_guild_voice_regions(
self, guild: snowflakes.SnowflakeishOr[guilds.PartialGuild],
self,
guild: snowflakes.SnowflakeishOr[guilds.PartialGuild],
) -> typing.Sequence[voices.VoiceRegion]:
...

@abc.abstractmethod
async def fetch_guild_invites(
self, guild: snowflakes.SnowflakeishOr[guilds.PartialGuild],
self,
guild: snowflakes.SnowflakeishOr[guilds.PartialGuild],
) -> typing.Sequence[invites.InviteWithMetadata]:
...

@abc.abstractmethod
async def fetch_integrations(
self, guild: snowflakes.SnowflakeishOr[guilds.PartialGuild],
self,
guild: snowflakes.SnowflakeishOr[guilds.PartialGuild],
) -> typing.Sequence[guilds.Integration]:
...

Expand Down
22 changes: 18 additions & 4 deletions hikari/applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,11 @@ def format_icon(self, *, ext: str = "png", size: int = 4096) -> typing.Optional[
return None

return routes.CDN_TEAM_ICON.compile_to_file(
constants.CDN_URL, team_id=self.id, hash=self.icon_hash, size=size, file_format=ext,
constants.CDN_URL,
team_id=self.id,
hash=self.icon_hash,
size=size,
file_format=ext,
)


Expand All @@ -373,7 +377,9 @@ class Application(snowflakes.Unique):
"""The client application that models may use for procedures."""

id: snowflakes.Snowflake = attr.ib(
eq=True, hash=True, repr=True,
eq=True,
hash=True,
repr=True,
)
"""The ID of this entity."""

Expand Down Expand Up @@ -480,7 +486,11 @@ def format_icon(self, *, ext: str = "png", size: int = 4096) -> typing.Optional[
return None

return routes.CDN_APPLICATION_ICON.compile_to_file(
constants.CDN_URL, application_id=self.id, hash=self.icon_hash, size=size, file_format=ext,
constants.CDN_URL,
application_id=self.id,
hash=self.icon_hash,
size=size,
file_format=ext,
)

@property
Expand Down Expand Up @@ -521,5 +531,9 @@ def format_cover_image(self, *, ext: str = "png", size: int = 4096) -> typing.Op
return None

return routes.CDN_APPLICATION_COVER.compile_to_file(
constants.CDN_URL, application_id=self.id, hash=self.cover_image_hash, size=size, file_format=ext,
constants.CDN_URL,
application_id=self.id,
hash=self.cover_image_hash,
size=size,
file_format=ext,
)
17 changes: 14 additions & 3 deletions hikari/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,22 @@ class PermissionOverwrite(snowflakes.Unique):
"""

id: snowflakes.Snowflake = attr.ib(
converter=snowflakes.Snowflake, eq=True, hash=True, repr=True,
converter=snowflakes.Snowflake,
eq=True,
hash=True,
repr=True,
)
"""The ID of this entity."""

type: PermissionOverwriteType = attr.ib(converter=PermissionOverwriteType, eq=True, hash=True, repr=True)
"""The type of entity this overwrite targets."""

allow: permissions.Permissions = attr.ib(
converter=permissions.Permissions, default=permissions.Permissions.NONE, eq=False, hash=False, repr=False,
converter=permissions.Permissions,
default=permissions.Permissions.NONE,
eq=False,
hash=False,
repr=False,
)
"""The permissions this overwrite allows."""

Expand Down Expand Up @@ -481,7 +488,11 @@ def format_icon(self, *, ext: str = "png", size: int = 4096) -> typing.Optional[
return None

return routes.CDN_CHANNEL_ICON.compile_to_file(
constants.CDN_URL, channel_id=self.id, hash=self.icon_hash, size=size, file_format=ext,
constants.CDN_URL,
channel_id=self.id,
hash=self.icon_hash,
size=size,
file_format=ext,
)


Expand Down
9 changes: 7 additions & 2 deletions hikari/embeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ def filename(self) -> str:
return self.resource.filename

def stream(
self, *, executor: typing.Optional[concurrent.futures.Executor] = None, head_only: bool = False,
self,
*,
executor: typing.Optional[concurrent.futures.Executor] = None,
head_only: bool = False,
) -> files.AsyncReaderContextManager[AsyncReaderT]:
"""Produce a stream of data for the resource.
Expand Down Expand Up @@ -525,7 +528,9 @@ def __warn_naive_datetime() -> None:
)

warnings.warn(
message, category=errors.HikariWarning, stacklevel=3,
message,
category=errors.HikariWarning,
stacklevel=3,
)

@property
Expand Down
26 changes: 21 additions & 5 deletions hikari/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,10 @@ def extension(self) -> typing.Optional[str]:

@abc.abstractmethod
def stream(
self, *, executor: typing.Optional[concurrent.futures.Executor] = None, head_only: bool = False,
self,
*,
executor: typing.Optional[concurrent.futures.Executor] = None,
head_only: bool = False,
) -> AsyncReaderContextManager[ReaderImplT]:
"""Produce a stream of data for the resource.
Expand Down Expand Up @@ -594,7 +597,10 @@ class WebResource(Resource[WebReader], abc.ABC):
__slots__: typing.Sequence[str] = ()

def stream(
self, *, executor: typing.Optional[concurrent.futures.Executor] = None, head_only: bool = False,
self,
*,
executor: typing.Optional[concurrent.futures.Executor] = None,
head_only: bool = False,
) -> AsyncReaderContextManager[WebReader]:
"""Start streaming the content into memory by downloading it.
Expand Down Expand Up @@ -834,7 +840,10 @@ def filename(self) -> str:
return self._filename

def stream(
self, *, executor: typing.Optional[concurrent.futures.Executor] = None, head_only: bool = False,
self,
*,
executor: typing.Optional[concurrent.futures.Executor] = None,
head_only: bool = False,
) -> AsyncReaderContextManager[FileReader]:
"""Start streaming the resource using a thread pool executor.
Expand Down Expand Up @@ -961,7 +970,11 @@ class Bytes(Resource[IteratorReader]):
"""The provided mimetype, if specified. Otherwise `builtins.None`."""

def __init__(
self, data: typing.Union[Rawish, LazyByteIteratorish], filename: str, /, mimetype: typing.Optional[str] = None,
self,
data: typing.Union[Rawish, LazyByteIteratorish],
filename: str,
/,
mimetype: typing.Optional[str] = None,
) -> None:
if isinstance(data, RAWISH_TYPES):
data = unwrap_bytes(data)
Expand All @@ -987,7 +1000,10 @@ def filename(self) -> str:
return self._filename

def stream(
self, *, executor: typing.Optional[concurrent.futures.Executor] = None, head_only: bool = False,
self,
*,
executor: typing.Optional[concurrent.futures.Executor] = None,
head_only: bool = False,
) -> AsyncReaderContextManager[IteratorReader]:
"""Start streaming the content in chunks.
Expand Down
Loading

0 comments on commit 65e06a0

Please sign in to comment.