Less strict dictionary merging in core #1507
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In
https://github.com/fsspec/filesystem_spec/blob/7b774c26e30e5ae60b5b63bf4e345a1b32028a4e/fsspec/core.py#L337C9-L337C41
the dictionaries
extra_kwargs
andkws
are merged withkw = dict(**extra_kwargs, **kws)
. This may be an issue when there is redundant information in the two dictionaries, resulting in aTypeError: dict() got multiple values for keyword argument
(indeed I have just faced this exact situation in a project). I understand it is correct to raise this error when the same key is mapped to different values, but it is not necessary when the values are the same.An alternative way to approach this merge is with
kw = extra_kwargs | kws
and raising the error only when there are overlapping keys with different values, something along the lines of