diff --git a/httpx/_compat.py b/httpx/_compat.py index 15e915a9..ed61e98f 100644 --- a/httpx/_compat.py +++ b/httpx/_compat.py @@ -7,9 +7,9 @@ import sys # `contextlib.asynccontextmanager` exists from Python 3.7 onwards. # For 3.6 we require the `async_generator` package for a backported version. -try: +if sys.version_info >= (3, 7): from contextlib import asynccontextmanager # type: ignore -except ImportError: +else: from async_generator import asynccontextmanager # type: ignore # noqa # Brotli support is optional