Closed
Description
The docs for defaultdict
say:
The first argument provides the initial value for the default_factory attribute; it defaults to None. All remaining arguments are treated the same as if they were passed to the dict constructor, including keyword arguments.
However, the second argument is currently treated as a generic type that influences the type of the first argument.
The following should be valid:
>>> dict([('foo', 'bar')])
{'foo': 'bar'}
>>> dct = collections.defaultdict(dict, [('foo', 'bar')])
>>> dct
defaultdict(<class 'dict'>, {'foo': 'bar'})
>>> dct['g']
{}
>>> dct
defaultdict(<class 'dict'>, {'foo': 'bar', 'g': {}})
However, we get the error error: Argument 1 to "defaultdict" has incompatible type "Type[Dict[Any, Any]]"; expected "Optional[Callable[[], str]]"
.
Metadata
Metadata
Assignees
Labels
No labels