You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since HTTPMessage does not derive from Mapping at runtime and is also not registered as implementing Mapping, it shouldn't be one in stubs either. See some related discussion in #3576. In my opinion, the correct fix is to add a MappingLike protocol to _typeshed and use that for the headers argument.
I don't think MappingLike should go to _typeshed, because the meaning of "mapping-like" depends on the code that uses it. For example, it could mean "has .items() method", "gives keys when iterating and values from .__getitem__()", or "has .keys() and .__getitem__(). A single protocol can't cover it all. We already have SupportsItems, SupportsKeysAndGetItem and a couple other classes, so we should just use those.
Example:
URLopener.http_error
has the argumentheaders: Mapping[str, str]
. It gets called with the value ofHTTPResponse.msg
which has the typeHTTPMessage
.The text was updated successfully, but these errors were encountered: