Fixed bug with empty options

This commit is contained in:
2023-02-12 01:24:43 +02:00
parent bd911b96cf
commit e08c172f68
2 changed files with 2 additions and 4 deletions

View File

@ -420,7 +420,7 @@ class Ziffers(Sequence):
# pylint: disable=locally-disabled, dangerous-default-value # pylint: disable=locally-disabled, dangerous-default-value
def init_opts(self, options=None): def init_opts(self, options=None):
"""Evaluate the Ziffers tree using the options""" """Evaluate the Ziffers tree using the options"""
if options is None: if options is None or len(options)<=0:
self.options = DEFAULT_OPTIONS self.options = DEFAULT_OPTIONS
else: else:
self.options.update(options) self.options.update(options)

View File

@ -40,8 +40,7 @@ def zparse(expr: str, **opts) -> Ziffers:
Ziffers: Returns Ziffers iterable parsed with the given options Ziffers: Returns Ziffers iterable parsed with the given options
""" """
parsed = parse_expression(expr) parsed = parse_expression(expr)
if opts: parsed.init_opts(opts)
parsed.init_opts(opts)
return parsed return parsed
@ -51,4 +50,3 @@ def zparse(expr: str, **opts) -> Ziffers:
def z(expr: str, **opts) -> Ziffers: def z(expr: str, **opts) -> Ziffers:
"""Shortened method name for zparse""" """Shortened method name for zparse"""
return zparse(expr, **opts) return zparse(expr, **opts)