We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Change the type of `Extensions` from `Mapping` to `MutableMapping`.
### Discussed in https://github.com/encode/httpx/discussions/2793

<div type='discussions-op-text'>

<sup>Originally posted by **karosis88** July 28, 2023</sup>
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.


```python
response = httpx.Response(200)
response.extensions['my_custom_extension'] = 'something'
```

OUTPUT 
```
error: Unsupported target for indexed assignment ("Mapping[Str, Any]")  [index]
```

The solution is to simply change the extension type from `Mapping` to `MutableMapping`, allowing us to add custom extensions after the response has been created.

[See also this pr](https://github.com/karosis88/hishel/pull/4)</div>

---

I believe the only change needed is in the "_models.py" file.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `httpx/_types.py`
Content:
```
1 """
2 Type definitions for type checking purposes.
3 """
4 
5 import ssl
6 from http.cookiejar import CookieJar
7 from typing import (
8     IO,
9     TYPE_CHECKING,
10     Any,
11     AsyncIterable,
12     AsyncIterator,
13     Callable,
14     Dict,
15     Iterable,
16     Iterator,
17     List,
18     Mapping,
19     NamedTuple,
20     Optional,
21     Sequence,
22     Tuple,
23     Union,
24 )
25 
26 if TYPE_CHECKING:  # pragma: no cover
27     from ._auth import Auth  # noqa: F401
28     from ._config import Proxy, Timeout  # noqa: F401
29     from ._models import Cookies, Headers, Request  # noqa: F401
30     from ._urls import URL, QueryParams  # noqa: F401
31 
32 
33 PrimitiveData = Optional[Union[str, int, float, bool]]
34 
35 RawURL = NamedTuple(
36     "RawURL",
37     [
38         ("raw_scheme", bytes),
39         ("raw_host", bytes),
40         ("port", Optional[int]),
41         ("raw_path", bytes),
42     ],
43 )
44 
45 URLTypes = Union["URL", str]
46 
47 QueryParamTypes = Union[
48     "QueryParams",
49     Mapping[str, Union[PrimitiveData, Sequence[PrimitiveData]]],
50     List[Tuple[str, PrimitiveData]],
51     Tuple[Tuple[str, PrimitiveData], ...],
52     str,
53     bytes,
54 ]
55 
56 HeaderTypes = Union[
57     "Headers",
58     Mapping[str, str],
59     Mapping[bytes, bytes],
60     Sequence[Tuple[str, str]],
61     Sequence[Tuple[bytes, bytes]],
62 ]
63 
64 CookieTypes = Union["Cookies", CookieJar, Dict[str, str], List[Tuple[str, str]]]
65 
66 CertTypes = Union[
67     # certfile
68     str,
69     # (certfile, keyfile)
70     Tuple[str, Optional[str]],
71     # (certfile, keyfile, password)
72     Tuple[str, Optional[str], Optional[str]],
73 ]
74 VerifyTypes = Union[str, bool, ssl.SSLContext]
75 TimeoutTypes = Union[
76     Optional[float],
77     Tuple[Optional[float], Optional[float], Optional[float], Optional[float]],
78     "Timeout",
79 ]
80 ProxiesTypes = Union[URLTypes, "Proxy", Dict[URLTypes, Union[None, URLTypes, "Proxy"]]]
81 
82 AuthTypes = Union[
83     Tuple[Union[str, bytes], Union[str, bytes]],
84     Callable[["Request"], "Request"],
85     "Auth",
86 ]
87 
88 RequestContent = Union[str, bytes, Iterable[bytes], AsyncIterable[bytes]]
89 ResponseContent = Union[str, bytes, Iterable[bytes], AsyncIterable[bytes]]
90 ResponseExtensions = Mapping[str, Any]
91 
92 RequestData = Mapping[str, Any]
93 
94 FileContent = Union[IO[bytes], bytes, str]
95 FileTypes = Union[
96     # file (or bytes)
97     FileContent,
98     # (filename, file (or bytes))
99     Tuple[Optional[str], FileContent],
100     # (filename, file (or bytes), content_type)
101     Tuple[Optional[str], FileContent, Optional[str]],
102     # (filename, file (or bytes), content_type, headers)
103     Tuple[Optional[str], FileContent, Optional[str], Mapping[str, str]],
104 ]
105 RequestFiles = Union[Mapping[str, FileTypes], Sequence[Tuple[str, FileTypes]]]
106 
107 RequestExtensions = Mapping[str, Any]
108 
109 
110 class SyncByteStream:
111     def __iter__(self) -> Iterator[bytes]:
112         raise NotImplementedError(
113             "The '__iter__' method must be implemented."
114         )  # pragma: no cover
115         yield b""  # pragma: no cover
116 
117     def close(self) -> None:
118         """
119         Subclasses can override this method to release any network resources
120         after a request/response cycle is complete.
121         """
122 
123 
124 class AsyncByteStream:
125     async def __aiter__(self) -> AsyncIterator[bytes]:
126         raise NotImplementedError(
127             "The '__aiter__' method must be implemented."
128         )  # pragma: no cover
129         yield b""  # pragma: no cover
130 
131     async def aclose(self) -> None:
132         pass
133
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/httpx/_types.py b/httpx/_types.py
--- a/httpx/_types.py
+++ b/httpx/_types.py
@@ -16,6 +16,7 @@
     Iterator,
     List,
     Mapping,
+    MutableMapping,
     NamedTuple,
     Optional,
     Sequence,
@@ -87,7 +88,7 @@
 
 RequestContent = Union[str, bytes, Iterable[bytes], AsyncIterable[bytes]]
 ResponseContent = Union[str, bytes, Iterable[bytes], AsyncIterable[bytes]]
-ResponseExtensions = Mapping[str, Any]
+ResponseExtensions = MutableMapping[str, Any]
 
 RequestData = Mapping[str, Any]
 
@@ -104,7 +105,7 @@
 ]
 RequestFiles = Union[Mapping[str, FileTypes], Sequence[Tuple[str, FileTypes]]]
 
-RequestExtensions = Mapping[str, Any]
+RequestExtensions = MutableMapping[str, Any]
 
 
 class SyncByteStream:

{"golden_diff": "diff --git a/httpx/_types.py b/httpx/_types.py\n--- a/httpx/_types.py\n+++ b/httpx/_types.py\n@@ -16,6 +16,7 @@\n     Iterator,\n     List,\n     Mapping,\n+    MutableMapping,\n     NamedTuple,\n     Optional,\n     Sequence,\n@@ -87,7 +88,7 @@\n \n RequestContent = Union[str, bytes, Iterable[bytes], AsyncIterable[bytes]]\n ResponseContent = Union[str, bytes, Iterable[bytes], AsyncIterable[bytes]]\n-ResponseExtensions = Mapping[str, Any]\n+ResponseExtensions = MutableMapping[str, Any]\n \n RequestData = Mapping[str, Any]\n \n@@ -104,7 +105,7 @@\n ]\n RequestFiles = Union[Mapping[str, FileTypes], Sequence[Tuple[str, FileTypes]]]\n \n-RequestExtensions = Mapping[str, Any]\n+RequestExtensions = MutableMapping[str, Any]\n \n \n class SyncByteStream:\n", "issue": "Change the type of `Extensions` from `Mapping` to `MutableMapping`.\n### Discussed in https://github.com/encode/httpx/discussions/2793\r\n\r\n<div type='discussions-op-text'>\r\n\r\n<sup>Originally posted by **karosis88** July 28, 2023</sup>\r\nI'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.\r\n\r\nUnfortunately, the type of extension is Mapping, so this is an error for mypy.\r\n\r\n\r\n```python\r\nresponse = httpx.Response(200)\r\nresponse.extensions['my_custom_extension'] = 'something'\r\n```\r\n\r\nOUTPUT \r\n```\r\nerror: Unsupported target for indexed assignment (\"Mapping[Str, Any]\")  [index]\r\n```\r\n\r\nThe solution is to simply change the extension type from `Mapping` to `MutableMapping`, allowing us to add custom extensions after the response has been created.\r\n\r\n[See also this pr](https://github.com/karosis88/hishel/pull/4)</div>\r\n\r\n---\r\n\r\nI believe the only change needed is in the \"_models.py\" file.\n", "before_files": [{"content": "\"\"\"\nType definitions for type checking purposes.\n\"\"\"\n\nimport ssl\nfrom http.cookiejar import CookieJar\nfrom typing import (\n    IO,\n    TYPE_CHECKING,\n    Any,\n    AsyncIterable,\n    AsyncIterator,\n    Callable,\n    Dict,\n    Iterable,\n    Iterator,\n    List,\n    Mapping,\n    NamedTuple,\n    Optional,\n    Sequence,\n    Tuple,\n    Union,\n)\n\nif TYPE_CHECKING:  # pragma: no cover\n    from ._auth import Auth  # noqa: F401\n    from ._config import Proxy, Timeout  # noqa: F401\n    from ._models import Cookies, Headers, Request  # noqa: F401\n    from ._urls import URL, QueryParams  # noqa: F401\n\n\nPrimitiveData = Optional[Union[str, int, float, bool]]\n\nRawURL = NamedTuple(\n    \"RawURL\",\n    [\n        (\"raw_scheme\", bytes),\n        (\"raw_host\", bytes),\n        (\"port\", Optional[int]),\n        (\"raw_path\", bytes),\n    ],\n)\n\nURLTypes = Union[\"URL\", str]\n\nQueryParamTypes = Union[\n    \"QueryParams\",\n    Mapping[str, Union[PrimitiveData, Sequence[PrimitiveData]]],\n    List[Tuple[str, PrimitiveData]],\n    Tuple[Tuple[str, PrimitiveData], ...],\n    str,\n    bytes,\n]\n\nHeaderTypes = Union[\n    \"Headers\",\n    Mapping[str, str],\n    Mapping[bytes, bytes],\n    Sequence[Tuple[str, str]],\n    Sequence[Tuple[bytes, bytes]],\n]\n\nCookieTypes = Union[\"Cookies\", CookieJar, Dict[str, str], List[Tuple[str, str]]]\n\nCertTypes = Union[\n    # certfile\n    str,\n    # (certfile, keyfile)\n    Tuple[str, Optional[str]],\n    # (certfile, keyfile, password)\n    Tuple[str, Optional[str], Optional[str]],\n]\nVerifyTypes = Union[str, bool, ssl.SSLContext]\nTimeoutTypes = Union[\n    Optional[float],\n    Tuple[Optional[float], Optional[float], Optional[float], Optional[float]],\n    \"Timeout\",\n]\nProxiesTypes = Union[URLTypes, \"Proxy\", Dict[URLTypes, Union[None, URLTypes, \"Proxy\"]]]\n\nAuthTypes = Union[\n    Tuple[Union[str, bytes], Union[str, bytes]],\n    Callable[[\"Request\"], \"Request\"],\n    \"Auth\",\n]\n\nRequestContent = Union[str, bytes, Iterable[bytes], AsyncIterable[bytes]]\nResponseContent = Union[str, bytes, Iterable[bytes], AsyncIterable[bytes]]\nResponseExtensions = Mapping[str, Any]\n\nRequestData = Mapping[str, Any]\n\nFileContent = Union[IO[bytes], bytes, str]\nFileTypes = Union[\n    # file (or bytes)\n    FileContent,\n    # (filename, file (or bytes))\n    Tuple[Optional[str], FileContent],\n    # (filename, file (or bytes), content_type)\n    Tuple[Optional[str], FileContent, Optional[str]],\n    # (filename, file (or bytes), content_type, headers)\n    Tuple[Optional[str], FileContent, Optional[str], Mapping[str, str]],\n]\nRequestFiles = Union[Mapping[str, FileTypes], Sequence[Tuple[str, FileTypes]]]\n\nRequestExtensions = Mapping[str, Any]\n\n\nclass SyncByteStream:\n    def __iter__(self) -> Iterator[bytes]:\n        raise NotImplementedError(\n            \"The '__iter__' method must be implemented.\"\n        )  # pragma: no cover\n        yield b\"\"  # pragma: no cover\n\n    def close(self) -> None:\n        \"\"\"\n        Subclasses can override this method to release any network resources\n        after a request/response cycle is complete.\n        \"\"\"\n\n\nclass AsyncByteStream:\n    async def __aiter__(self) -> AsyncIterator[bytes]:\n        raise NotImplementedError(\n            \"The '__aiter__' method must be implemented.\"\n        )  # pragma: no cover\n        yield b\"\"  # pragma: no cover\n\n    async def aclose(self) -> None:\n        pass\n", "path": "httpx/_types.py"}], "after_files": [{"content": "\"\"\"\nType definitions for type checking purposes.\n\"\"\"\n\nimport ssl\nfrom http.cookiejar import CookieJar\nfrom typing import (\n    IO,\n    TYPE_CHECKING,\n    Any,\n    AsyncIterable,\n    AsyncIterator,\n    Callable,\n    Dict,\n    Iterable,\n    Iterator,\n    List,\n    Mapping,\n    MutableMapping,\n    NamedTuple,\n    Optional,\n    Sequence,\n    Tuple,\n    Union,\n)\n\nif TYPE_CHECKING:  # pragma: no cover\n    from ._auth import Auth  # noqa: F401\n    from ._config import Proxy, Timeout  # noqa: F401\n    from ._models import Cookies, Headers, Request  # noqa: F401\n    from ._urls import URL, QueryParams  # noqa: F401\n\n\nPrimitiveData = Optional[Union[str, int, float, bool]]\n\nRawURL = NamedTuple(\n    \"RawURL\",\n    [\n        (\"raw_scheme\", bytes),\n        (\"raw_host\", bytes),\n        (\"port\", Optional[int]),\n        (\"raw_path\", bytes),\n    ],\n)\n\nURLTypes = Union[\"URL\", str]\n\nQueryParamTypes = Union[\n    \"QueryParams\",\n    Mapping[str, Union[PrimitiveData, Sequence[PrimitiveData]]],\n    List[Tuple[str, PrimitiveData]],\n    Tuple[Tuple[str, PrimitiveData], ...],\n    str,\n    bytes,\n]\n\nHeaderTypes = Union[\n    \"Headers\",\n    Mapping[str, str],\n    Mapping[bytes, bytes],\n    Sequence[Tuple[str, str]],\n    Sequence[Tuple[bytes, bytes]],\n]\n\nCookieTypes = Union[\"Cookies\", CookieJar, Dict[str, str], List[Tuple[str, str]]]\n\nCertTypes = Union[\n    # certfile\n    str,\n    # (certfile, keyfile)\n    Tuple[str, Optional[str]],\n    # (certfile, keyfile, password)\n    Tuple[str, Optional[str], Optional[str]],\n]\nVerifyTypes = Union[str, bool, ssl.SSLContext]\nTimeoutTypes = Union[\n    Optional[float],\n    Tuple[Optional[float], Optional[float], Optional[float], Optional[float]],\n    \"Timeout\",\n]\nProxiesTypes = Union[URLTypes, \"Proxy\", Dict[URLTypes, Union[None, URLTypes, \"Proxy\"]]]\n\nAuthTypes = Union[\n    Tuple[Union[str, bytes], Union[str, bytes]],\n    Callable[[\"Request\"], \"Request\"],\n    \"Auth\",\n]\n\nRequestContent = Union[str, bytes, Iterable[bytes], AsyncIterable[bytes]]\nResponseContent = Union[str, bytes, Iterable[bytes], AsyncIterable[bytes]]\nResponseExtensions = MutableMapping[str, Any]\n\nRequestData = Mapping[str, Any]\n\nFileContent = Union[IO[bytes], bytes, str]\nFileTypes = Union[\n    # file (or bytes)\n    FileContent,\n    # (filename, file (or bytes))\n    Tuple[Optional[str], FileContent],\n    # (filename, file (or bytes), content_type)\n    Tuple[Optional[str], FileContent, Optional[str]],\n    # (filename, file (or bytes), content_type, headers)\n    Tuple[Optional[str], FileContent, Optional[str], Mapping[str, str]],\n]\nRequestFiles = Union[Mapping[str, FileTypes], Sequence[Tuple[str, FileTypes]]]\n\nRequestExtensions = MutableMapping[str, Any]\n\n\nclass SyncByteStream:\n    def __iter__(self) -> Iterator[bytes]:\n        raise NotImplementedError(\n            \"The '__iter__' method must be implemented.\"\n        )  # pragma: no cover\n        yield b\"\"  # pragma: no cover\n\n    def close(self) -> None:\n        \"\"\"\n        Subclasses can override this method to release any network resources\n        after a request/response cycle is complete.\n        \"\"\"\n\n\nclass AsyncByteStream:\n    async def __aiter__(self) -> AsyncIterator[bytes]:\n        raise NotImplementedError(\n            \"The '__aiter__' method must be implemented.\"\n        )  # pragma: no cover\n        yield b\"\"  # pragma: no cover\n\n    async def aclose(self) -> None:\n        pass\n", "path": "httpx/_types.py"}]}