From cff7327558979c3088ff5ac792a4e3d0149fd4e9 Mon Sep 17 00:00:00 2001 From: Zach Parks Date: Mon, 3 Jun 2024 03:45:01 -0500 Subject: [PATCH] Utils: Fix mistake made with `KeyedDefaultDict` from #1933 that broke tracker functionality. (#3433) --- Utils.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Utils.py b/Utils.py index eea81a2d..a7fd7f4f 100644 --- a/Utils.py +++ b/Utils.py @@ -458,8 +458,14 @@ class KeyedDefaultDict(collections.defaultdict): """defaultdict variant that uses the missing key as argument to default_factory""" default_factory: typing.Callable[[typing.Any], typing.Any] - def __init__(self, default_factory: typing.Callable[[Any], Any] = None, **kwargs): - super().__init__(default_factory, **kwargs) + def __init__(self, + default_factory: typing.Callable[[Any], Any] = None, + seq: typing.Union[typing.Mapping, typing.Iterable, None] = None, + **kwargs): + if seq is not None: + super().__init__(default_factory, seq, **kwargs) + else: + super().__init__(default_factory, **kwargs) def __missing__(self, key): self[key] = value = self.default_factory(key)