Make defaultdict.default_factory Optional. (#2401)

The API allows for setting this to `None`.  It makes the defaultdict behave more like a regular dict.

Fixes #2375.
This commit is contained in:
Matt Gilson
2018-08-18 22:22:15 -04:00
committed by Jelle Zijlstra
parent 0386f3daec
commit ebea29a0ed

View File

@@ -305,7 +305,7 @@ class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]):
_DefaultDictT = TypeVar('_DefaultDictT', bound=defaultdict)
class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):
default_factory = ... # type: Callable[[], _VT]
default_factory = ... # type: Optional[Callable[[], _VT]]
@overload
def __init__(self, **kwargs: _VT) -> None: ...