Core: document KeyedDefaultDict

This commit is contained in:
Fabian Dill
2022-08-12 06:52:01 +02:00
committed by black-sliver
parent b702ae482b
commit 2e428f906c

View File

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