From e08c172f68cb20dd5d8e73bf3354f1e292d68f35 Mon Sep 17 00:00:00 2001 From: Miika Alonen Date: Sun, 12 Feb 2023 01:24:43 +0200 Subject: [PATCH] Fixed bug with empty options --- ziffers/classes.py | 2 +- ziffers/parser.py | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ziffers/classes.py b/ziffers/classes.py index 6dab368..d5d3ad6 100644 --- a/ziffers/classes.py +++ b/ziffers/classes.py @@ -420,7 +420,7 @@ class Ziffers(Sequence): # pylint: disable=locally-disabled, dangerous-default-value def init_opts(self, options=None): """Evaluate the Ziffers tree using the options""" - if options is None: + if options is None or len(options)<=0: self.options = DEFAULT_OPTIONS else: self.options.update(options) diff --git a/ziffers/parser.py b/ziffers/parser.py index 4e5c7dd..1b83122 100644 --- a/ziffers/parser.py +++ b/ziffers/parser.py @@ -40,8 +40,7 @@ def zparse(expr: str, **opts) -> Ziffers: Ziffers: Returns Ziffers iterable parsed with the given options """ parsed = parse_expression(expr) - if opts: - parsed.init_opts(opts) + parsed.init_opts(opts) return parsed @@ -51,4 +50,3 @@ def zparse(expr: str, **opts) -> Ziffers: def z(expr: str, **opts) -> Ziffers: """Shortened method name for zparse""" return zparse(expr, **opts) - \ No newline at end of file