Fix type annotation on keyword argument in copy(**add_or_replace) #54
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.
Fix type annotation on keyword argument in
copy(**add_or_replace)
The type annotation for keyword arguments describes the type of the value, not of the kwargs as a whole itself. (See https://www.python.org/dev/peps/pep-0484/#id37)
This is because the keys of a keyword argument paramater is always
str
.So the signature of of
copy(self, **add_or_replace: Dict[_K, _V])
means "add_or_replace is a keyword arguments parameter whose values are of typeDict[_K, _V]
", probably not what was intended.Now it is set to be
**add_or_replace: _V
, which means it can accept keyword arguments of type_V
Incidentally, the return type annotation is incorrect if the self
immutabledict
didn't haveText
keys or a supertype thereof (as now it is going to haveText
keys in addition to whatever_K
was), but that is a separate issue.