Repository: encode/httpx
File: httpx/_client.py (Python)

Code before:
    def close(self) -> None:
        """
        Close transport and proxies.
        """
        self._transport.close()
        for proxy in self._proxies.values():
            if proxy is not None:
                proxy.close()

    def __enter__(self) -> "Client":
        self._transport.__enter__()
        for proxy in self._proxies.values():
            if proxy is not None:
                proxy.__enter__()
        return self

    def __exit__(
        self,
        exc_type: typing.Type[BaseException] = None,
        exc_value: BaseException = None,
        traceback: TracebackType = None,
    ) -> None:
        self._transport.__exit__()
        for proxy in self._proxies.values():
            if proxy is not None:
                proxy.__exit__()


class AsyncClient(BaseClient):
    """
    An asynchronous HTTP client, with connection pooling, HTTP/2, redirects,
    cookie persistence, etc.

    Usage:

    ```python
    >>> async with httpx.AsyncClient() as client:
    >>>     response = await client.get('https://example.org')
    ```

    **Parameters:**

    * **auth** - *(optional)* An authentication class to use when sending
    requests.
    * **params** - *(optional)* Query parameters to include in request URLs, as
    a string, dictionary, or list of two-tuples.
    * **headers** - *(optional)* Dictionary of HTTP headers to include when
    sending requests.
    * **cookies** - *(optional)* Dictionary of Cookie items to include when
    sending requests.
    * **verify** - *(optional)* SSL certificates (a.k.a CA bundle) used to

Review comment (suggestion):
I believe we need to send the exception information down, like this:

```suggestion
        self._transport.__exit__(exc_type, exc_value, traceback)
        for proxy in self._proxies.values():
            if proxy is not None:
                proxy.__exit__(exc_type, exc_value, traceback)
```

(I'm actually surprised the code works without passing these - HTTPCore transports allow `= None` but I'm not _sure_ this is part of the context manager protocol strictly?)

Code after:
    def close(self) -> None:
        """
        Close transport and proxies.
        """
        self._transport.close()
        for proxy in self._proxies.values():
            if proxy is not None:
                proxy.close()

    def __enter__(self) -> "Client":
        self._transport.__enter__()
        for proxy in self._proxies.values():
            if proxy is not None:
                proxy.__enter__()
        return self

    def __exit__(
        self,
        exc_type: typing.Type[BaseException] = None,
        exc_value: BaseException = None,
        traceback: TracebackType = None,
    ) -> None:
        self._transport.__exit__(exc_type, exc_value, traceback)
        for proxy in self._proxies.values():
            if proxy is not None:
                proxy.__exit__(exc_type, exc_value, traceback)


class AsyncClient(BaseClient):
    """
    An asynchronous HTTP client, with connection pooling, HTTP/2, redirects,
    cookie persistence, etc.

    Usage:

    ```python
    >>> async with httpx.AsyncClient() as client:
    >>>     response = await client.get('https://example.org')
    ```

    **Parameters:**

    * **auth** - *(optional)* An authentication class to use when sending
    requests.
    * **params** - *(optional)* Query parameters to include in request URLs, as
    a string, dictionary, or list of two-tuples.
    * **headers** - *(optional)* Dictionary of HTTP headers to include when
    sending requests.
    * **cookies** - *(optional)* Dictionary of Cookie items to include when
    sending requests.
    * **verify** - *(optional)* SSL certificates (a.k.a CA bundle) used to