diff options
author | 2024-02-19 21:35:56 +0000 | |
---|---|---|
committer | 2024-03-04 12:35:02 +0000 | |
commit | ccd94c90d33b7aee85117078576684fab5055ce5 (patch) | |
tree | f54d2e3c71f12fe4613026d5a35ceae4dea4bd5a /pydis_core/utils | |
parent | ruff lint fix: Run remaining auto-fixable rules (diff) |
ruff lint fix: Manual non-breaking changes
Diffstat (limited to 'pydis_core/utils')
-rw-r--r-- | pydis_core/utils/__init__.py | 2 | ||||
-rw-r--r-- | pydis_core/utils/checks.py | 8 | ||||
-rw-r--r-- | pydis_core/utils/cooldown.py | 4 | ||||
-rw-r--r-- | pydis_core/utils/function.py | 3 | ||||
-rw-r--r-- | pydis_core/utils/interactions.py | 2 | ||||
-rw-r--r-- | pydis_core/utils/pagination.py | 2 | ||||
-rw-r--r-- | pydis_core/utils/scheduling.py | 4 |
7 files changed, 13 insertions, 12 deletions
diff --git a/pydis_core/utils/__init__.py b/pydis_core/utils/__init__.py index 1636b35e..72531787 100644 --- a/pydis_core/utils/__init__.py +++ b/pydis_core/utils/__init__.py @@ -35,7 +35,7 @@ def apply_monkey_patches() -> None: Patches discord's internal ``send_typing`` method so that it ignores 403 errors from Discord. When under heavy load Discord has added a CloudFlare worker to this route, which causes 403 errors to be thrown. """ - _monkey_patches._apply_monkey_patches() + _monkey_patches._apply_monkey_patches() # noqa: SLF001 __all__ = [ diff --git a/pydis_core/utils/checks.py b/pydis_core/utils/checks.py index 33a78516..50fb2082 100644 --- a/pydis_core/utils/checks.py +++ b/pydis_core/utils/checks.py @@ -99,7 +99,7 @@ def in_whitelist_check( def cooldown_with_role_bypass( rate: int, per: float, - type: BucketType = BucketType.default, + type_: BucketType = BucketType.default, *, bypass_roles: Iterable[int] ) -> Callable: @@ -124,11 +124,11 @@ def cooldown_with_role_bypass( bypass = set(bypass_roles) # This handles the actual cooldown logic. - buckets = CooldownMapping(Cooldown(rate, per, type)) + buckets = CooldownMapping(Cooldown(rate, per, type_)) # Will be called after the command has been parse but before it has been invoked, ensures that # the cooldown won't be updated if the user screws up their input to the command. - async def predicate(cog: Cog, ctx: Context) -> None: + async def predicate(_: Cog, ctx: Context) -> None: nonlocal bypass, buckets if any(role.id in bypass for role in ctx.author.roles): @@ -152,7 +152,7 @@ def cooldown_with_role_bypass( "This means it has to be above the command decorator in the code." ) - command._before_invoke = predicate + command._before_invoke = predicate # noqa: SLF001 return command diff --git a/pydis_core/utils/cooldown.py b/pydis_core/utils/cooldown.py index d3f278ab..90711c93 100644 --- a/pydis_core/utils/cooldown.py +++ b/pydis_core/utils/cooldown.py @@ -83,7 +83,7 @@ class _SeparatedArguments: for item in call_arguments: try: hash(item) - except TypeError: + except TypeError: # noqa: PERF203 non_hashable.append(item) else: hashable.append(item) @@ -152,7 +152,7 @@ class _CommandCooldownManager: await asyncio.sleep(initial_delay) while True: await asyncio.sleep(60 * 60) - weak_self()._delete_stale_items() + weak_self()._delete_stale_items() # noqa: SLF001 def _delete_stale_items(self) -> None: """Remove expired items from internal collections.""" diff --git a/pydis_core/utils/function.py b/pydis_core/utils/function.py index 0df3a953..5c0d7ba4 100644 --- a/pydis_core/utils/function.py +++ b/pydis_core/utils/function.py @@ -51,9 +51,10 @@ def get_arg_value(name_or_pos: Argument, arguments: BoundArgs) -> typing.Any: try: _name, value = arg_values[arg_pos] - return value except IndexError: raise ValueError(f"Argument position {arg_pos} is out of bounds.") + else: + return value elif isinstance(name_or_pos, str): arg_name = name_or_pos try: diff --git a/pydis_core/utils/interactions.py b/pydis_core/utils/interactions.py index 7c5e5101..41b98dc5 100644 --- a/pydis_core/utils/interactions.py +++ b/pydis_core/utils/interactions.py @@ -43,7 +43,7 @@ async def _handle_modify_message(message: Message, action: Literal["edit", "dele elif isinstance(e, NotFound): log.info(f"Could not find message {message.id} when attempting to {action} it.") else: - log.exception(f"Could not {action} message {message.id} due to Discord HTTP error:\n{e!s}") + log.exception(f"Could not {action} message {message.id} due to Discord HTTP error:") class ViewWithUserAndRoleCheck(ui.View): diff --git a/pydis_core/utils/pagination.py b/pydis_core/utils/pagination.py index aac75ae1..dd7f1edc 100644 --- a/pydis_core/utils/pagination.py +++ b/pydis_core/utils/pagination.py @@ -266,7 +266,7 @@ class LinePaginator(Paginator): for line in lines: try: paginator.add_line(line, empty=empty) - except Exception: + except Exception: # noqa: PERF203 log.exception(f"Failed to add line to paginator: '{line}'") raise # Should propagate else: diff --git a/pydis_core/utils/scheduling.py b/pydis_core/utils/scheduling.py index aa90b1e1..621fdd81 100644 --- a/pydis_core/utils/scheduling.py +++ b/pydis_core/utils/scheduling.py @@ -112,7 +112,7 @@ class Scheduler: def schedule_later( self, - delay: int | float, + delay: float, task_id: abc.Hashable, coroutine: abc.Coroutine ) -> None: @@ -156,7 +156,7 @@ class Scheduler: async def _await_later( self, - delay: int | float, + delay: float, task_id: abc.Hashable, coroutine: abc.Coroutine ) -> None: |