diff options
| -rw-r--r-- | docs/utils.py | 2 | ||||
| -rw-r--r-- | pydis_core/_bot.py | 4 | ||||
| -rw-r--r-- | pydis_core/exts/source.py | 16 | ||||
| -rw-r--r-- | pydis_core/site_api.py | 4 | ||||
| -rw-r--r-- | pydis_core/utils/function.py | 8 | ||||
| -rw-r--r-- | pydis_core/utils/paste_service.py | 4 | ||||
| -rw-r--r-- | pyproject.toml | 1 |
7 files changed, 22 insertions, 17 deletions
diff --git a/docs/utils.py b/docs/utils.py index 567f0d18..d11f0d9c 100644 --- a/docs/utils.py +++ b/docs/utils.py @@ -98,7 +98,7 @@ def linkcode_resolve(repo_link: str, domain: str, info: dict[str, str]) -> str | # These are ClassVars added by pydantic. # Since they're not in our source code, we cannot resolve them to a url. return None - raise Exception(f"Could not find symbol `{symbol_name}` in {module.__name__}.") + raise Exception(f"Could not find symbol `{symbol_name}` in {module.__name__}.") from None start, end = pos _, offset = inspect.getsourcelines(symbol[-2]) diff --git a/pydis_core/_bot.py b/pydis_core/_bot.py index 783715dd..2510bd05 100644 --- a/pydis_core/_bot.py +++ b/pydis_core/_bot.py @@ -317,8 +317,8 @@ class BotBase(commands.Bot): try: await self.ping_services() - except Exception as e: # noqa: BLE001 - raise StartupError(e) + except Exception as e: + raise StartupError(e) from e async def ping_services(self) -> None: """Ping all required services on setup to ensure they are up before starting.""" diff --git a/pydis_core/exts/source.py b/pydis_core/exts/source.py index 5fe29306..1770258d 100644 --- a/pydis_core/exts/source.py +++ b/pydis_core/exts/source.py @@ -129,14 +129,14 @@ class SourceCode(commands.Cog, description="Displays information about the bot's src = type(source_item) try: filename = inspect.getsourcefile(src) - except TypeError: - raise commands.BadArgument("Cannot get source for a dynamically-created object.") + except TypeError as e: + raise commands.BadArgument("Cannot get source for a dynamically-created object.") from e if source_type != _SourceType.tag: try: lines, first_line_no = inspect.getsourcelines(src) - except OSError: - raise commands.BadArgument("Cannot get source for a dynamically-created object.") + except OSError as e: + raise commands.BadArgument("Cannot get source for a dynamically-created object.") from e lines_extension = f"#L{first_line_no}-L{first_line_no+len(lines)-1}" else: @@ -196,6 +196,12 @@ class SourceCode(commands.Cog, description="Displays information about the bot's embed = Embed(title=title, description=description) embed.add_field(name="Source Code", value=f"[Go to GitHub]({url})") line_text = f":{first_line}" if first_line else "" - embed.set_footer(text=f"{location}{line_text}", icon_url=GITHUB_AVATAR) + + if source_type == _SourceType.core_cog or source_type == _SourceType.core_command: + project_name = "pydis_core" + else: + project_name = self.bot.user.name + + embed.set_footer(text=f"{project_name} \N{BLACK CIRCLE} {location}{line_text}", icon_url=GITHUB_AVATAR) return embed diff --git a/pydis_core/site_api.py b/pydis_core/site_api.py index f948cde3..bcad781a 100644 --- a/pydis_core/site_api.py +++ b/pydis_core/site_api.py @@ -92,9 +92,9 @@ class APIClient: try: response_json = await response.json() raise ResponseCodeError(response=response, response_json=response_json) - except aiohttp.ContentTypeError: + except aiohttp.ContentTypeError as e: response_text = await response.text() - raise ResponseCodeError(response=response, response_text=response_text) + raise ResponseCodeError(response=response, response_text=response_text) from e async def request(self, method: str, endpoint: str, *, raise_for_status: bool = True, **kwargs) -> dict | None: """ diff --git a/pydis_core/utils/function.py b/pydis_core/utils/function.py index 2d2b7923..f2872207 100644 --- a/pydis_core/utils/function.py +++ b/pydis_core/utils/function.py @@ -51,16 +51,16 @@ def get_arg_value(name_or_pos: Argument, arguments: BoundArgs) -> typing.Any: try: _name, value = arg_values[arg_pos] - except IndexError: - raise ValueError(f"Argument position {arg_pos} is out of bounds.") + except IndexError as e: + raise ValueError(f"Argument position {arg_pos} is out of bounds.") from e else: return value elif isinstance(name_or_pos, str): arg_name = name_or_pos try: return arguments[arg_name] - except KeyError: - raise ValueError(f"Argument {arg_name!r} doesn't exist.") + except KeyError as e: + raise ValueError(f"Argument {arg_name!r} doesn't exist.") from e else: raise TypeError("'arg' must either be an int (positional index) or a str (keyword).") diff --git a/pydis_core/utils/paste_service.py b/pydis_core/utils/paste_service.py index 140e6cdc..26b7c7d7 100644 --- a/pydis_core/utils/paste_service.py +++ b/pydis_core/utils/paste_service.py @@ -98,8 +98,8 @@ async def send_to_paste_service( try: async with http_session.get(f"{paste_url}/api/v1/lexer") as response: response_json = await response.json() # Supported lexers are the keys. - except HTTPException: - raise PasteUploadError("Could not fetch supported lexers from selected paste_url.") + except HTTPException as e: + raise PasteUploadError("Could not fetch supported lexers from selected paste_url.") from e _lexers_supported_by_pastebin[paste_url] = list(response_json) diff --git a/pyproject.toml b/pyproject.toml index 3121d1b3..13ad72e1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -104,7 +104,6 @@ select = ["ALL"] ignore = [ "A005", "ANN002", "ANN003", "ANN204", "ANN206", "ANN401", - "B904", "C401", "C408", "C901", "COM812", "CPY001", |