From 0bf2aba0bacfe3b56d418277040ca439324e4448 Mon Sep 17 00:00:00 2001 From: Ethan Paul <24588726+enpaul@users.noreply.github.com> Date: Tue, 23 Nov 2021 19:49:26 -0500 Subject: [PATCH] Fix typing and linting errors Fix typing error in checksum path factory Fix immediate reraise in manip resource handler Fix unsilenced warning in manip protocol function --- kodak/database/_shared.py | 2 +- kodak/manipulations.py | 3 ++- kodak/resources/manip.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/kodak/database/_shared.py b/kodak/database/_shared.py index 9dbd3e6..b918cd0 100644 --- a/kodak/database/_shared.py +++ b/kodak/database/_shared.py @@ -47,7 +47,7 @@ class Checksum(NamedTuple): hasher = constructor() view = memoryview(bytearray(1024 * 1024)) - with path.open("rb", buffering=0) as infile: + with Path(path).open("rb", buffering=0) as infile: for chunk in iter(lambda: infile.readinto(view), 0): # type: ignore hasher.update(view[:chunk]) diff --git a/kodak/manipulations.py b/kodak/manipulations.py index 2689bdb..e61b928 100644 --- a/kodak/manipulations.py +++ b/kodak/manipulations.py @@ -98,7 +98,8 @@ def crop(image: Image.Image, config: configuration.ManipConfig) -> Image.Image: def black_and_white( - image: Image.Image, config: configuration.ManipConfig + image: Image.Image, + config: configuration.ManipConfig, # pylint: disable=unused-argument ) -> Image.Image: """Convert an image to full-depth black and white""" logger = logging.getLogger(__name__) diff --git a/kodak/resources/manip.py b/kodak/resources/manip.py index 5295317..31f4325 100644 --- a/kodak/resources/manip.py +++ b/kodak/resources/manip.py @@ -24,7 +24,7 @@ class ImageManip(KodakResource): manip_config = flask.current_app.appconfig.manips[manip_name] format_ = constants.ImageFormat[format_name.upper()] except KeyError: - raise + raise RuntimeError("Manip or format doesn't exist") from None with database.interface.atomic(): parent = database.ImageRecord.get(database.ImageRecord.name == image_name)