From 957fab6e6036804857687edd3ff482664dec0a3e Mon Sep 17 00:00:00 2001 From: Chris Beaven Date: Mon, 5 Aug 2024 10:37:19 +1200 Subject: [PATCH] Fix parsing crop=False --- easy_images/options.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/easy_images/options.py b/easy_images/options.py index 17ee057..eecf31a 100644 --- a/easy_images/options.py +++ b/easy_images/options.py @@ -62,10 +62,10 @@ def __init__(self, bound=None, string="", /, **options): for key, value in bound.__dict__.items(): context[key] = value for key in self.__slots__: - value = options.get(key) - if isinstance(value, Variable): - value = value.resolve(context) - if value or value == 0: + if key in options: + value = options[key] + if isinstance(value, Variable): + value = value.resolve(context) parse_func = getattr(self, f"parse_{key}") value = parse_func(value, **options) elif key in self._defaults: @@ -92,7 +92,9 @@ def parse_quality(value, **options) -> int: raise ValueError(f"Invalid quality value {value}") @staticmethod - def parse_crop(value, **options) -> tuple[float, float]: + def parse_crop(value, **options) -> tuple[float, float] | None: + if not value: + return None if value is True: return (0.5, 0.5) try: