Core: document KeyedDefaultDict
This commit is contained in:
parent
b702ae482b
commit
2e428f906c
3
Utils.py
3
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
|
||||
|
|
Loading…
Reference in New Issue