Change the type of extension from Mapping to MutableMapping. #2793
-
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 |
Beta Was this translation helpful? Give feedback.
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. |
Beta Was this translation helpful? Give feedback.
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.