Utils: Fix mistake made with `KeyedDefaultDict` from #1933 that broke tracker functionality. (#3433)

This commit is contained in:
Zach Parks 2024-06-03 03:45:01 -05:00 committed by GitHub
parent 70e9ccb13c
commit cff7327558
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 2 deletions

View File

@ -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)