Skip to content

Commit

Permalink
chore(pre-commit): pre-commit autoupdate (#1909)
Browse files Browse the repository at this point in the history
* chore(pre-commit): pre-commit autoupdate

updates:
- [github.com/PyCQA/autoflake: v2.0.0 → v2.0.1](PyCQA/autoflake@v2.0.0...v2.0.1)
- [github.com/psf/black: 22.12.0 → 23.1.0](psf/black@22.12.0...23.1.0)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* remove stale comment

The preview feature was moved to stable in v23, and the bug previously preventing us from using the new style was fixed in psf/black#3430

Signed-off-by: BobDotCom <[email protected]>

* try preview flag for black

Signed-off-by: BobDotCom <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* style(pre-commit): disable black --preview flag

---------

Signed-off-by: BobDotCom <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: BobDotCom <[email protected]>
  • Loading branch information
pre-commit-ci[bot] and BobDotCom authored Feb 10, 2023
1 parent 08af163 commit 4fc423d
Show file tree
Hide file tree
Showing 28 changed files with 169 additions and 92 deletions.
5 changes: 2 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repos:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/PyCQA/autoflake
rev: v2.0.0
rev: v2.0.1
hooks:
- id: autoflake
# args:
Expand All @@ -27,10 +27,9 @@ repos:
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.1.0
hooks:
- id: black
# See https://github.com/psf/black/issues/2188#issuecomment-1289317647 for why we can't use the --preview flag.
args: [--safe, --quiet]
- repo: https://github.com/Pierre-Sassoulas/black-disable-checker
rev: v1.1.3
Expand Down
6 changes: 4 additions & 2 deletions discord/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@
# setuptools_scm is not installed
__version__ = "0.0.0"
warnings.warn(
"Package is not installed, and setuptools_scm is not installed. "
f"As a fallback, {__name__}.__version__ will be set to {__version__}",
(
"Package is not installed, and setuptools_scm is not installed. "
f"As a fallback, {__name__}.__version__ will be set to {__version__}"
),
RuntimeWarning,
stacklevel=2,
)
Expand Down
8 changes: 5 additions & 3 deletions discord/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,11 @@ async def _edit(
"allow": allow.value,
"deny": deny.value,
"id": target.id,
"type": _Overwrites.ROLE
if isinstance(target, Role)
else _Overwrites.MEMBER,
"type": (
_Overwrites.ROLE
if isinstance(target, Role)
else _Overwrites.MEMBER
),
}

perms.append(payload)
Expand Down
2 changes: 1 addition & 1 deletion discord/application_role_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __init__(

def __repr__(self):
return (
f"<ApplicationRoleConnectionMetadata "
"<ApplicationRoleConnectionMetadata "
f"type={self.type!r} "
f"key={self.key!r} "
f"name={self.name!r} "
Expand Down
8 changes: 6 additions & 2 deletions discord/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,15 @@ def __init__(
self.emoji = PartialEmoji.from_str(emoji)
else:
raise TypeError(
f"emoji must be a Emoji, PartialEmoji, or str and not {emoji.__class__!r}"
"emoji must be a Emoji, PartialEmoji, or str and not"
f" {emoji.__class__!r}"
)

def __repr__(self) -> str:
return f"<ForumTag id={self.id} name={self.name!r} emoji={self.emoji!r} moderated={self.moderated}>"
return (
"<ForumTag"
f" id={self.id} name={self.name!r} emoji={self.emoji!r} moderated={self.moderated}>"
)

def __str__(self) -> str:
return self.name
Expand Down
10 changes: 6 additions & 4 deletions discord/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ def __new__(cls: type[CogMeta], *args: Any, **kwargs: Any) -> CogMeta:
# r.e type ignore, type-checker complains about overriding a ClassVar
new_cls.__cog_commands__ = tuple(c._update_copy(cmd_attrs) if not hasattr(c, "add_to") else c for c in new_cls.__cog_commands__) # type: ignore

name_filter = (
lambda c: "app"
name_filter = lambda c: (
"app"
if isinstance(c, ApplicationCommand)
else ("bridge" if not hasattr(c, "add_to") else "ext")
)
Expand Down Expand Up @@ -1019,8 +1019,10 @@ def load_extensions(
loaded = self.load_extension(
ext_path, package=package, recursive=recursive, store=store
)
loaded_extensions.update(loaded) if store else loaded_extensions.extend(
loaded
(
loaded_extensions.update(loaded)
if store
else loaded_extensions.extend(loaded)
)

return loaded_extensions
Expand Down
6 changes: 4 additions & 2 deletions discord/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -910,8 +910,10 @@ async def _invoke(self, ctx: ApplicationContext) -> None:
):
arg = ctx.guild.get_channel_or_thread(int(arg))
_data["_invoke_flag"] = True
arg._update(_data) if isinstance(arg, Thread) else arg._update(
ctx.guild, _data
(
arg._update(_data)
if isinstance(arg, Thread)
else arg._update(ctx.guild, _data)
)
else:
obj_type = None
Expand Down
4 changes: 3 additions & 1 deletion discord/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,9 @@ def category(self) -> AuditLogActionCategory | None:
AuditLogAction.thread_create: AuditLogActionCategory.create,
AuditLogAction.thread_update: AuditLogActionCategory.update,
AuditLogAction.thread_delete: AuditLogActionCategory.delete,
AuditLogAction.application_command_permission_update: AuditLogActionCategory.update,
AuditLogAction.application_command_permission_update: (
AuditLogActionCategory.update
),
AuditLogAction.auto_moderation_rule_create: AuditLogActionCategory.create,
AuditLogAction.auto_moderation_rule_update: AuditLogActionCategory.update,
AuditLogAction.auto_moderation_rule_delete: AuditLogActionCategory.delete,
Expand Down
16 changes: 10 additions & 6 deletions discord/ext/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2010,9 +2010,11 @@ def predicate(ctx):
# ctx.guild is None doesn't narrow ctx.author to Member
getter = functools.partial(discord.utils.get, ctx.author.roles) # type: ignore
if any(
getter(id=item) is not None
if isinstance(item, int)
else getter(name=item) is not None
(
getter(id=item) is not None
if isinstance(item, int)
else getter(name=item) is not None
)
for item in items
):
return True
Expand Down Expand Up @@ -2072,9 +2074,11 @@ def predicate(ctx):
me = ctx.me
getter = functools.partial(discord.utils.get, me.roles)
if any(
getter(id=item) is not None
if isinstance(item, int)
else getter(name=item) is not None
(
getter(id=item) is not None
if isinstance(item, int)
else getter(name=item) is not None
)
for item in items
):
return True
Expand Down
22 changes: 14 additions & 8 deletions discord/ext/pages/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,21 +766,27 @@ def add_button(self, button: PaginatorButton):
self.buttons[button.button_type] = {
"object": discord.ui.Button(
style=button.style,
label=button.label
if button.label or button.emoji
else button.button_type.capitalize()
if button.button_type != "page_indicator"
else f"{self.current_page + 1}/{self.page_count + 1}",
label=(
button.label
if button.label or button.emoji
else (
button.button_type.capitalize()
if button.button_type != "page_indicator"
else f"{self.current_page + 1}/{self.page_count + 1}"
)
),
disabled=button.disabled,
custom_id=button.custom_id,
emoji=button.emoji,
row=button.row,
),
"label": button.label,
"loop_label": button.loop_label,
"hidden": button.disabled
if button.button_type != "page_indicator"
else not self.show_indicator,
"hidden": (
button.disabled
if button.button_type != "page_indicator"
else not self.show_indicator
),
}
self.buttons[button.button_type]["object"].callback = button.callback
button.paginator = self
Expand Down
6 changes: 4 additions & 2 deletions discord/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,10 @@ def run(self):
while not self._stop_ev.wait(self.interval):
if self._last_recv + self.heartbeat_timeout < time.perf_counter():
_log.warning(
"Shard ID %s has stopped responding to the gateway. Closing and"
" restarting.",
(
"Shard ID %s has stopped responding to the gateway. Closing and"
" restarting."
),
self.shard_id,
)
coro = self.ws.close(4000)
Expand Down
8 changes: 5 additions & 3 deletions discord/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -1140,9 +1140,11 @@ def _create_channel(
"allow": allow.value,
"deny": deny.value,
"id": target.id,
"type": abc._Overwrites.ROLE
if isinstance(target, Role)
else abc._Overwrites.MEMBER,
"type": (
abc._Overwrites.ROLE
if isinstance(target, Role)
else abc._Overwrites.MEMBER
),
}

perms.append(payload)
Expand Down
12 changes: 8 additions & 4 deletions discord/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,10 @@ async def request(
response, use_clock=self.use_clock
)
_log.debug(
"A rate limit bucket has been exhausted (bucket: %s,"
" retry: %s).",
(
"A rate limit bucket has been exhausted (bucket:"
" %s, retry: %s)."
),
bucket,
delta,
)
Expand Down Expand Up @@ -334,8 +336,10 @@ async def request(
is_global = data.get("global", False)
if is_global:
_log.warning(
"Global rate limit has been hit. Retrying in %.2f"
" seconds.",
(
"Global rate limit has been hit. Retrying in"
" %.2f seconds."
),
retry_after,
)
self._global_over.clear()
Expand Down
1 change: 0 additions & 1 deletion discord/iterators.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,6 @@ def create_member(self, data):

class BanIterator(_AsyncIterator["BanEntry"]):
def __init__(self, guild, limit=None, before=None, after=None):

self.guild = guild
self.limit = limit
self.after = after
Expand Down
4 changes: 2 additions & 2 deletions discord/opus.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def set_bandwidth(self, req: BAND_CTL) -> None:
if req not in band_ctl:
raise KeyError(
f"{req!r} is not a valid bandwidth setting. Try one of:"
f' {",".join(band_ctl)}'
f" {','.join(band_ctl)}"
)

k = band_ctl[req]
Expand All @@ -408,7 +408,7 @@ def set_signal_type(self, req: SIGNAL_CTL) -> None:
if req not in signal_ctl:
raise KeyError(
f"{req!r} is not a valid bandwidth setting. Try one of:"
f' {",".join(signal_ctl)}'
f" {','.join(signal_ctl)}"
)

k = signal_ctl[req]
Expand Down
5 changes: 2 additions & 3 deletions discord/partial_emoji.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,8 @@ def _to_partial(self) -> PartialEmoji:

def _to_forum_tag_payload(
self,
) -> (
TypedDict("TagPayload", {"emoji_id": int, "emoji_name": None})
| TypedDict("TagPayload", {"emoji_id": None, "emoji_name": str})
) -> TypedDict("TagPayload", {"emoji_id": int, "emoji_name": None}) | TypedDict(
"TagPayload", {"emoji_id": None, "emoji_name": str}
):
if self.id is None:
return {"emoji_id": None, "emoji_name": self.name}
Expand Down
Loading

0 comments on commit 4fc423d

Please sign in to comment.