Skip to content

Commit

Permalink
Technically more accurate.
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePhar committed Jun 2, 2024
1 parent 5d858f2 commit 757e331
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,11 @@ 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, *args, **kwargs):
super().__init__(default_factory, *args, **kwargs)
def __init__(self,
default_factory: typing.Callable[[Any], Any] = None,
default: typing.Union[typing.Mapping, typing.Iterable, None] = None,
**kwargs):
super().__init__(default_factory, default, **kwargs)

def __missing__(self, key):
self[key] = value = self.default_factory(key)
Expand Down

0 comments on commit 757e331

Please sign in to comment.