From 11d177eeaac042acb55c99edcb0c01c66cdda664 Mon Sep 17 00:00:00 2001 From: Wolfgang Müller Date: Thu, 14 Nov 2024 16:55:17 +0100 Subject: backend/lint: Properly chain exceptions This fixes flake8-bugbear's B904 [1]. [1] https://docs.astral.sh/ruff/rules/raise-without-from-inside-except/ --- src/hircine/api/inputs.py | 8 ++++---- src/hircine/plugins/scrapers/ehentai_api.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/hircine/api/inputs.py b/src/hircine/api/inputs.py index c88bcce..a9cf272 100644 --- a/src/hircine/api/inputs.py +++ b/src/hircine/api/inputs.py @@ -277,13 +277,13 @@ class ComicTagsUpdateInput(UpdateInputList): def parse_input(cls, id): try: return [int(i) for i in id.split(":")] - except ValueError: + except ValueError as err: raise APIException( InvalidParameterError( parameter="id", text="ComicTag ID must be specified as :", ) - ) + ) from err @classmethod async def get_from_ids(cls, ids, ctx: MutationContext): @@ -383,13 +383,13 @@ class ComicTagsUpsertInput(UpsertInputList): raise ValueError() return namespace, tag - except ValueError: + except ValueError as err: raise APIException( InvalidParameterError( parameter="name", text="ComicTag name must be specified as :", ) - ) + ) from err @classmethod async def get_from_names(cls, input, ctx: MutationContext, on_missing: OnMissing): diff --git a/src/hircine/plugins/scrapers/ehentai_api.py b/src/hircine/plugins/scrapers/ehentai_api.py index 70fcf57..3720b92 100644 --- a/src/hircine/plugins/scrapers/ehentai_api.py +++ b/src/hircine/plugins/scrapers/ehentai_api.py @@ -69,7 +69,7 @@ class EHentaiAPIScraper(Scraper): handler = ExHentaiHandler() yield from handler.scrape(response) - except json.JSONDecodeError: - raise ScrapeError("Could not parse JSON response") + except json.JSONDecodeError as err: + raise ScrapeError("Could not parse JSON response") from err else: raise ScrapeError(f"Request failed with status code {request.status_code}'") -- cgit v1.2.3-2-gb3c3