inline annotations for datastructures #2974
Merged
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.
Removed the stub files, and redid the annotations inline. Addressed some mypy findings this affected in other places. As I was going through everything I did a bit of refactoring and took some notes as well:
super().method(...)
instead ofBaseClass.method(self, ...)
. There are some places where the non-super pattern is still needed.super().__init__()
in some subclasses that were missing it.iter_multi_items
and__ini__
/update
/etc methods acceptMapping
,Collection
, andIterable
instead of more specific types likedict
,list
, andtuple
.keys()
/values()
/items()
returnIterable
instead ofKeysView
/etc, which doesn't match theMapping
interface. I couldn't think of a general way to efficiently implement these for the structures, and no one has ever brought it up, so I'm leaving it.Headers
inherits fromMutableMapping
instead of nothing. This was true in the stubs, but wasn't actually reflected in the code.FileMultiDict.add_file
accepts anos.PathLike
path as the first argument (instead of only astr
path).__getitem__
/get
/pop
/etc only specify overrides for parameters that make sense. I couldn't figure out how to specify a complete set of overrides, and it didn't seem necessary anyway.Headers.getlist
was be refactored to not checktype is not None
every iteration.Mapping.update(arg, /, **kwargs)
andHeaders.set(key, value, /, **kwargs)
rather than taking and checking*args
._get_mode
parameter fromHeaders.__getitem__
, refactor various methods that usedself[key]
to work without needing that weird implementation.CombinedMultiDict.to_dict
was an exact copy of thesuper
implementation.fixes #2970