diff options
author | 2024-02-19 21:35:56 +0000 | |
---|---|---|
committer | 2024-03-04 12:35:02 +0000 | |
commit | ccd94c90d33b7aee85117078576684fab5055ce5 (patch) | |
tree | f54d2e3c71f12fe4613026d5a35ceae4dea4bd5a | |
parent | ruff lint fix: Run remaining auto-fixable rules (diff) |
ruff lint fix: Manual non-breaking changes
-rw-r--r-- | docs/conf.py | 4 | ||||
-rw-r--r-- | docs/utils.py | 2 | ||||
-rw-r--r-- | pydis_core/__init__.py | 12 | ||||
-rw-r--r-- | pydis_core/_bot.py | 4 | ||||
-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 |
11 files changed, 24 insertions, 23 deletions
diff --git a/docs/conf.py b/docs/conf.py index 5205b013..94246fe4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -18,14 +18,14 @@ from sphinx.application import Sphinx logger = sphinx.util.logging.getLogger(__name__) # Handle the path not being set correctly in actions. -sys.path.insert(0, os.path.abspath("..")) +sys.path.insert(0, Path("..").resolve()) from docs import utils # noqa: E402 # -- Project information ----------------------------------------------------- project = "Pydis Core" -copyright = "2021, Python Discord" +copyright = "2021, Python Discord" # noqa: A001 author = "Python Discord" REPO_LINK = "https://github.com/python-discord/bot-core" diff --git a/docs/utils.py b/docs/utils.py index 796eca3d..de40cf6b 100644 --- a/docs/utils.py +++ b/docs/utils.py @@ -204,7 +204,7 @@ def build_api_doc() -> None: return result = subprocess.run(cmd, cwd=build_root, stdout=subprocess.PIPE, check=True, env=os.environ) # noqa: S603 - logger.debug("api-doc Output:\n" + result.stdout.decode(encoding="utf-8") + "\n") + logger.debug(f"api-doc Output:\n{result.stdout.decode(encoding='utf-8')}\n") cleanup() diff --git a/pydis_core/__init__.py b/pydis_core/__init__.py index a00a9fd4..44e4f14b 100644 --- a/pydis_core/__init__.py +++ b/pydis_core/__init__.py @@ -5,15 +5,15 @@ from pydis_core._bot import BotBase, StartupError from pydis_core.utils.pagination import EmptyPaginatorEmbedError, LinePaginator, PaginationEmojis __all__ = [ - async_stats, BotBase, - exts, - utils, - site_api, - StartupError, + EmptyPaginatorEmbedError, LinePaginator, PaginationEmojis, - EmptyPaginatorEmbedError + StartupError, + async_stats, + exts, + site_api, + utils, ] __all__ = [module.__name__ for module in __all__] diff --git a/pydis_core/_bot.py b/pydis_core/_bot.py index 56cedb28..365b67b3 100644 --- a/pydis_core/_bot.py +++ b/pydis_core/_bot.py @@ -286,7 +286,7 @@ class BotBase(commands.Bot): try: await self.ping_services() - except Exception as e: + except Exception as e: # noqa: BLE001 raise StartupError(e) async def ping_services(self) -> None: @@ -319,7 +319,7 @@ class BotBase(commands.Bot): await self._resolver.close() if getattr(self.stats, "_transport", False): - self.stats._transport.close() + self.stats._transport.close() # noqa: SLF001 if self._statsd_timerhandle: self._statsd_timerhandle.cancel() 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: |