From 2e428f906c922dd033470f4c94fafa37978942dd Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Fri, 12 Aug 2022 06:52:01 +0200 Subject: [PATCH] Core: document KeyedDefaultDict --- Utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Utils.py b/Utils.py index b94e2862..aafd6014 100644 --- a/Utils.py +++ b/Utils.py @@ -411,6 +411,9 @@ def restricted_loads(s): 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 __missing__(self, key): self[key] = value = self.default_factory(key) return value