mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
This commit is contained in:
10
Utils.py
10
Utils.py
@@ -458,8 +458,14 @@ class KeyedDefaultDict(collections.defaultdict):
|
|||||||
"""defaultdict variant that uses the missing key as argument to default_factory"""
|
"""defaultdict variant that uses the missing key as argument to default_factory"""
|
||||||
default_factory: typing.Callable[[typing.Any], typing.Any]
|
default_factory: typing.Callable[[typing.Any], typing.Any]
|
||||||
|
|
||||||
def __init__(self, default_factory: typing.Callable[[Any], Any] = None, **kwargs):
|
def __init__(self,
|
||||||
super().__init__(default_factory, **kwargs)
|
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):
|
def __missing__(self, key):
|
||||||
self[key] = value = self.default_factory(key)
|
self[key] = value = self.default_factory(key)
|
||||||
|
Reference in New Issue
Block a user