Change the type of extension from Mapping to MutableMapping. #2793
Answered
by
lovelydinosaur
karpetrosyan
asked this question in
Ideas
|
I'm working on a library that implements HTTP Caching for httpx and httpcore (it provides transports and connection pools), and I'd like to add an extension that simply indicates whether or not the response was taken from the cache. Unfortunately, the type of extension is Mapping, so this is an error for mypy. response = httpx.Response(200)
response.extensions['my_custom_extension'] = 'something'OUTPUT The solution is to simply change the extension type from |
Answered by
lovelydinosaur
Jul 28, 2023
Replies: 1 comment 5 replies
|
Given that response (and request) headers are a mutable mapping, it would be API consistent for response (and request) extensions to also be typed as a mutable mapping, yep. |
5 replies
Answer selected by
lovelydinosaur
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Given that response (and request) headers are a mutable mapping, it would be API consistent for response (and request) extensions to also be typed as a mutable mapping, yep.